Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jenkins pipeline mandatory text parameters in input step

We are building several pipeline tasks in Jenkins to make life easier on some deploy jobs. One of them requires manual input of several parameters. For that we are using an input step like this:

def userInput = input ( message : 'Select deployment versión and input deployment code:',
     parameters: [[$class: 'TextParameterDefinition', defaultValue: '', description: 'Clarive code', name: 'code']] )

Those parameters are mandatory. We didn't find in the documentation any property that will make the TextParameterDefinition mandatory. For now we are re running the step until all parameters are not null, but the solution is a bit confusing for the user.

Is there another way to handle mandatory parameters that avoids running the same step on a loop?

like image 656
aitkiar Avatar asked Apr 19 '17 13:04

aitkiar


1 Answers

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

There's an open bug to support it.

In the meantime 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..")
}
like image 83
hakamairi Avatar answered Sep 22 '22 09:09

hakamairi