Jenkins: how to make parameters required in a parameterized build?

There's a plugin called "Validating String Parameter". When you install this plugin in your project, you see an additional option of Validating String Parameter while adding parameters. Using this option will show an additional column of Regular expression. For non-empty string parameter write this inside Regular Expression field:

^(?!\s*$).+

This will finally make your string parameter mandatory.


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


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')
                }
            }
        }
    }

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..")
}