tkcn
tkcn

Reputation: 566

Dynamic parameter selection on jenkins

I have a build/deploy job on jenkins, and user can select multiple items to be deployed with multi select parameter. I retrieve those values dynamically from db table with a groovy script.

Problem is that some of the variables should be linked. Meaning; when user selects item X, item A and item B also should be selected.

Is there a way of triggering a selection event on jenkins multi select? or should I use something else?

Thanks.

Upvotes: 3

Views: 2823

Answers (1)

tkcn
tkcn

Reputation: 566

After spending some time I found a way to do this using Active Choices Plugin

1- I kept my initial extended choice parameter lets name it COMPONENTLIST

2- Then I created another paramateter as Active Choices Reactive Reference Parameter lets name it COMPONENT_IDS

2a- I added COMPONENTLIST as referenced parameter in COMPONENT_IDS. And set the Choice Type as Formatted HTML and also selected Omit value field

2b- I used following groovy script to collect initial selection and make modifications on it and returned as in step 2c

def output = COMPONENTLIST.split(',').collect{it as int}

2c- tricky part here! It is different how you pass the paramater to build stage. Following line helped me to pass COMPONENT_IDS to build.

output = output.join(",") 
return "<b>${output}</b><input type=\"hidden\" name=\"value\" value=\"${output}\" />"

Upvotes: 2

Related Questions