Anastazja  Bondarenko
Anastazja Bondarenko

Reputation: 199

How to convert MultiSelect values from Active Choice Parameter in Jenkins into an array or list?

I have parameterized job with 'list' MultiSelect parameter in Jenkins: enter image description here

I want to build this job only with selected values: enter image description here

And for this purpose, I want to pass this selected values to pipeline script in this job and convert them into an array or list.

The following code doesn't work properly: enter image description here

Please, help me to write the proper code in groovy to convert selected values to array or list.

Thanks, Anastasiia

Upvotes: 1

Views: 6135

Answers (1)

ojasvi
ojasvi

Reputation: 26

Assuming parameter name "list" and property setting described in question, below pipeline code worked for me.

String[] arr= "${params.list}".split(','); for (x in arr) { echo "$x \n" }

This will print each selected values on new line.

Upvotes: 1

Related Questions