Problem-
I have a variable as follows def var1 = ['a','b','c']
and I want to render this variable as a radio button in the jenkins pipeline Input request stage. This variable is not static and the values inside it can change with each run i.e. the variable can be initialised as def var1 = ['q','w','e']
on the second run of the pipeline.
I am not able to display dynamic variable list as a radio button in jenkins.
What I used-
parameters: [extendedChoice(name: 'DeployTo', type: 'PT_RADIO', value: "$var1", visibleItemCount: 5, description: 'Select item')]
But this seems to print every item a,b,c
or q,w,e
in a single line instead of different radio buttons
PS- I'm fairly new to Jenkins and any help would be appreciated, thanks
CodePudding user response:
You would indeed think that the type for the choice values would be list<string>
because that is super intuitive, but for some reason it is a comma-delimited string instead:
String var1 = 'a, b, c'
and you will have the different choices displayed as desired.
Additionally, you may have had some complications by resolving the var1
like "$var1"
which would force an implicit cast to a string since you are interpolating. You could avoid this by using the first class expression support value: var1
.