Search code examples
jenkinsgroovyjenkins-pluginsjenkins-pipeline

How to get input steps ouput in jenkins-pipeline


I used in my pipeline a input steps as you can see below :

input(
         message : "some message",
         parameters: [
          [$class: 'ChoiceParameterDefinition',
            choices: string ,
            description: 'description',
            name:'input'
         ]
        ]
      )

I wanted to use the name input that I configure to get the value put in the input like this ${input}, but it didn't work. I also tried to put it in a var like this :

def reg = input : messages : "", paramaters: [...]

But It doesn't work either, so I don't understand how I can get the param that the user chose and didn't find how to do in the do.

Regards,


Solution

  • Try use this code:

    def userInput = input(id: 'userInput', message: 'some message', parameters: [
        [$class: 'ChoiceParameterDefinition', choices: string, description: 'description', name:'input'],
        ])
        VARAIBLE = userInput
    

    It's work For me. If you need add more ChoiceParameterDefinition code should look like that:

    def userInput = input(id: 'userInput', message: 'some message', parameters: [
        [$class: 'ChoiceParameterDefinition', choices: string, description: 'description1', name:'input1'],
        [$class: 'ChoiceParameterDefinition', choices: string, description: 'description2', name:'input2'],
        ])
        VARAIBLE1 = userInput['input1']
        VARAIBLE2 = userInput['input2']