Parameterized Jenkins Pipeline: Choices not showing up

9.6k Views Asked by At

I am trying to setup my pipeline as a Parameterized Pipeline using Single_select choice parameters.

My pipeline header looks as follows:

properties(
    [
        parameters([
            [
                $class: 'ChoiceParameter', 
                choiceType: 'PT_SINGLE_SELECT', 
                description: 'Select your testcase', 
                filterable: false, 
                name: 'testCases', 
                choices: ['HappyFlow', 'NewYork_HappyFlow']
            ]
        ]
    ), 
        pipelineTriggers([])
    ]
)

What happens when I am running my pipeline is the following:

Jenkins leaves the dropdown empty instead of giving me the options I specified in my pipeline properties

Jenkins leaves the dropdown empty instead of giving me the options I specified in my pipeline properties

How would I get the dropdown to be filled with the parameters from my pipeline properties?

2

There are 2 best solutions below

1
On BEST ANSWER

This worked for me:

   parameters([choice(choices:['HappyFlow', 'NewYork_HappyFlow'], description: 'Select your testcase', name: 'testCases')          
        ])
1
On

It sounds like you might be affected by JENKINS-26143: Workflow Snippet Generator - Incorrect format for Input with Choice Parameter. I think a fix is out for it in Jenkins 2.112 based on the comments on the issue, but for now, you can change choices from:

choices: ['HappyFlow', 'NewYork_HappyFlow']

to

choices: 'HappyFlow\nNewYork_HappyFlow'