Princy
Princy

Reputation: 633

Multi select values options jenkins

I am trying to create a job where I have to select multiple values for one parameter. env: dev1, dev2, qa1, qa2 etc I want to be able to select dev1 & dev2 to update certain values. Is there a way/plugin for Jenkins to handle it?

Upvotes: 44

Views: 106392

Answers (2)

Edu Castrillon
Edu Castrillon

Reputation: 577

Since Extended Choice Parameter plugin has now security issues, I would suggest Active Choices instead, using for example a simple checkbox configuration. For your example, you would add an "Active Choices Parameter", select "Groovy Script" and add the possible values (mark as selected the ones you want selected by default):

values for active choices parameter

Then you only need to choose the style you want for the rendering, like check boxes:

render parameter as check boxes

The result:

enter image description here

Upvotes: 2

Technext
Technext

Reputation: 8107

Extended Choice Parameter plugin is the way to go for such requirement. You need to select Extended Choice Parameter from the drop-down list as shown below:

enter image description here

In Name text-box, assign a name. For example, Environment. This is the name with which you will be accessing all the values (dev1,dev2,...) that you will select while triggering the build. Now, in Simple Parameter Types section, you will see another drop-down with the name Parameter Type. Select Multi Select from that drop-down. Now, in Choose Source for Value section, enter the values (dev1,dev2,qa1,qa2,...) in Value box. Comma (,) is the default delimiter. Refer screenshot below:

enter image description here

Once you are done with the above settings, you will then have to access the selected option in your script (using variable assigned to Name as described above) and decide the course of action.

Upvotes: 101

Related Questions