2

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?

Community
  • 1
  • 1
Ceesiebird
  • 696
  • 2
  • 11
  • 24

2 Answers2

3

This worked for me:

   parameters([choice(choices:['HappyFlow', 'NewYork_HappyFlow'], description: 'Select your testcase', name: 'testCases')          
        ])
sirineBEJI
  • 1,170
  • 2
  • 14
  • 25
  • Thank you for your clear answer, I managed to get it working. I did have to change out the standard array formatting to the suggested string format of @mkobit The code that eventually worked for me looks like this: `properties([parameters([choice(choices:'HappyFlow\nNewYork_HappyFlow',description: 'Select your testcase',name: 'testCases') ])])` – Ceesiebird Apr 17 '18 at 14:33
1

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' 
mkobit
  • 43,979
  • 12
  • 156
  • 150
  • Thank you for your answer, I was indeed aware of this bug, but ran into a formatting issue before running into this issue. Your answer together with the answer of @codeGeass helped me out tremendously. – Ceesiebird Apr 17 '18 at 14:30