27
votes

In Jenkins is there a plugin for parameterized builds to make the parameters required? The fields under the standard "This build is parameterized" option do not seem to provide that.

Clarification: by "required" I mean that the build will not execute until the field is populated with a value. This would obviously preclude automated triggers.

3

3 Answers

17
votes

The accepted answer is no longer valid.

There was a plugin that did that but is no longer maintained.

There's an open bug to support it.

In the mean time what you can do is check if your parameter is present and if not throw an error like:

if (params.SomeParam == null) {
    error("Build failed because of this and that..")
}
15
votes

This is the plugin i use to do this type of stuff: link...
You can set a regular expression to validate the input against

8
votes

Couldn't comment to answer Miguel's question, so answering here:

To fail a build if a parameter is not set, one could do something like this:

stage('Checkout') 
    {
        steps
        {
            checkout scm
            script 
            {
                if (params.myParam == '') { // and/or whatever condition you want
                    currentBuild.result = 'ABORTED'
                    error('myParam not set')
                }
            }
        }
    }