Choice Parameter from Shared LIbrary Step

15 views
Skip to first unread message

Ven H

unread,
Dec 18, 2020, 1:53:05 PM12/18/20
to jenkins...@googlegroups.com
Is it possible to populate a Choice parameter values (choices) with values retrieved from a Shared Library Step? Please help.

Regards,
Venkatesh

Senthil Nathan

unread,
Dec 18, 2020, 2:18:07 PM12/18/20
to jenkins...@googlegroups.com
Yes. In below example the choice_list can come from a shared pipeline library.

Eg)
Jenkinsfile:
========
choice_list=["choice1", "choice2", choice3"]
properties([                                                                                                                                                  
            parameters([                                                                                                                                      
              choice(name: 'mychoiceparam', choices:choice_list, description: 'my choices')])
])    

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/CAPp28erSn6zVWDG3--wTLgWT%2BGqVPSBWWwfvrNicqH0B3pZYdQ%40mail.gmail.com.

Ven H

unread,
Dec 18, 2020, 2:29:47 PM12/18/20
to jenkins...@googlegroups.com
Thanks a lot, Senthil. Can it be a Shared Library Step or a Class method only?. It will be great, if you can please help with some examples.

Regards,
Venkatesh


Senthil Nathan

unread,
Dec 18, 2020, 2:46:00 PM12/18/20
to jenkins...@googlegroups.com
You have to create a list from the return value of the library step. 

I don't know what library step you are using so cannot provide specific example.

Ven H

unread,
Dec 19, 2020, 12:44:57 AM12/19/20
to jenkins...@googlegroups.com
Let's say I have the following use case. I have 3 choice parameters, namely, Country, State, City. I have shared library steps to GetCountries, then GetStates with country as argument and then GetCities with country and state as arguments. In my pipeline job, I will have 3 Choice parameters, one each for Country, State and City, with a cascading functionality, which is, when I select a Country, the states will be populated accordingly and upon selection of a state, cities will be populated accordingly. 

choice(name: 'Country', description: 'Select Country', choices:'GetCountriesFromSharedLibStep')
choice(name: 'State', description: 'Select State', choices:'GetStatesFromSharedLibStep('${params.Country}')  
choice(name: 'City', description: 'Select City', choices:'GetCitiesFromSharedLibStep('${params.Country}', '${params.State}' )   

Has anyone had this kind of a requirement. If so, how to achieve this? Please help with some examples / code.

Regards,
Venkatesh


Ven H

unread,
Dec 22, 2020, 2:09:08 PM12/22/20
to jenkins...@googlegroups.com
Can anyone please help?


Regards,
Venkatesh

Reply all
Reply to author
Forward
0 new messages