Dynamic Parameter question

629 views
Skip to first unread message

alok kumar

unread,
May 5, 2014, 11:05:32 AM5/5/14
to jenkin...@googlegroups.com, jenkins...@googlegroups.com
Hi All,
We have a requirement in one of our Jenkins parameterized build project where we need to populate a selection of options in one parameter  based on the selection that was made before in another parameter i.e. dynamically populating the second parameter based on the first one.

What is the best way to do this? I need to have check boxes as options in the second parameter based on the selection of a single choice parameter in the first one.

E.g. say that we select car in the first parameter, I should get to choose from Ford, Toyota, Honda, Subaru, etc in the next parameter and that should be check boxes.

Is there a way to achieve this requirement? Also, how do we access the value of a parameter in a groovy script in another parameter?

Any help would be deeply appreciated.

Thanks in advance,
Alok

Ioannis Moutsatsos

unread,
May 9, 2014, 1:38:31 PM5/9/14
to jenkin...@googlegroups.com, jenkins...@googlegroups.com
I think that all the capability that you need is available to the uno-choice plugin developed by the BioUno project.

This plugin generates dynamic choice selections from a groovy script. You can use one or more parameters from the current Jenkins job form to parameterize the groovy script and it will update the list when on eof them changes (before submitting the build).
Finally, you can display the choices as a single or multi-select drop down list or as a checkbox or radio button options.

The plug-ins developed for BioUno are too niche-specific and thus aren’t released to Jenkins update center. In order to install the plug-ins you have to add the BioUno update center.
See here for instructions

Hope it helps.
Best regards
Ioannis

alok kumar

unread,
May 19, 2014, 6:13:29 AM5/19/14
to jenkins...@googlegroups.com, jenkin...@googlegroups.com
Hi Loannis,
Thanks for guiding me.
Can you please provide me an example groovy script meant to do this kind of work?
I am a little lost as I can even see any help icon for the way the script should be written using the other job parameters.

Thanks,
Alok

Ioannis Moutsatsos

unread,
May 19, 2014, 7:07:47 AM5/19/14
to jenkin...@googlegroups.com

In the reference parameter option write a comma separated list of the form parameters you would like your script to use. Then use them as parameters in your script. I can provide some additional details when I get to work later today.

--
You received this message because you are subscribed to a topic in the Google Groups "Jenkins Developers" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/jenkinsci-dev/3kfNtNr-4u4/unsubscribe.
To unsubscribe from this group and all its topics, send an email to jenkinsci-de...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

alok kumar

unread,
May 19, 2014, 9:19:33 AM5/19/14
to jenkin...@googlegroups.com

Thanks. That would be of great help. I will wait for your mail

You received this message because you are subscribed to the Google Groups "Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-de...@googlegroups.com.

Bruno P. Kinoshita

unread,
May 19, 2014, 10:24:16 AM5/19/14
to jenkin...@googlegroups.com

Hi there! Chiming in.

I've updated the uno-choice Wiki, please take a look https://github.com/biouno/uno-choice-plugin/wiki

Ioannis, I believe you have the rights to edit the Wiki too, so feel free to add better examples or add/edit pages :) I added a few examples I had in my computer. 

Hope that helps
Bruno


From: alok kumar <alok.k...@gmail.com>
To: jenkin...@googlegroups.com
Sent: Monday, May 19, 2014 10:19 AM
Subject: Re: Dynamic Parameter question

Ioannis Moutsatsos

unread,
May 19, 2014, 12:01:29 PM5/19/14
to jenkins...@googlegroups.com, jenkin...@googlegroups.com
Hi Alok

I don't know why Bruno's (one of the Biouno's founders)  reply did not show here but:

Hi there! Chiming in.
I've updated the uno-choice Wiki, please take a look https://github.com/biouno/uno-choice-plugin/wiki
Ioannis, I believe you have the rights to edit the Wiki too, so feel free to add better examples or add/edit pages :) I added a few examples I had in my computer. 
Hope that helps
Bruno

I just checked the wiki and it now has some pretty solid documentation on how to script with the reference parameters.
Check it out and let me know if you need any more specific examples.

Best regards
Ioannis


On Monday, May 5, 2014 11:05:32 AM UTC-4, alok kumar wrote:

alok kumar

unread,
May 19, 2014, 12:05:45 PM5/19/14
to jenkin...@googlegroups.com, jenkins...@googlegroups.com

Thanks Loannis and Bruno. That was great help. I will try it and let you know

--

Ioannis Moutsatsos

unread,
May 19, 2014, 12:07:24 PM5/19/14
to jenkin...@googlegroups.com
Hi Bruno;

The wiki looks pretty good now! I was planning helping with some examples but you beat me to it!
Anyway, I will try to write something that could be complementary to your documentation. 

I'm testing v 0.11 today. So far so good!

I also could get the image gallery to work with images from another project. So that's quite important!
Will send additional feedback by the end of the day.

Thanks and best regards
Ioannis
Best regards
--Ioannis--

Ioannis K. Moutsatsos
imout...@gmail.com

Bruno P. Kinoshita

unread,
May 19, 2014, 12:21:39 PM5/19/14
to jenkin...@googlegroups.com
Hi Ioannis!

It was in my todo list too, as well as writing Javascript unit tests for the plug-in (still haven't learned how to properly do that :)

One feature that I think we can remove is the pattern for archived artifacts. I had a different idea of how to use that, but I think it is now not necessary. Feel free to add/update issues and we can work on them and cut a new release later this week.

Feel free to send suggestions too Alok, or let us know if there is anything missing/broken.

Cheers
Bruno


From: Ioannis Moutsatsos <imout...@gmail.com>
To: jenkin...@googlegroups.com
Sent: Monday, May 19, 2014 1:07 PM

alok kumar

unread,
May 19, 2014, 1:03:59 PM5/19/14
to jenkin...@googlegroups.com
Hi Loannis and Bruno,
Thanks a lot for all the help and It did work the way you have shown in the example.
I have a couple of doubts here:

1. Does this work only with the choice parameter? OR it can be used with the extended choice, extensible choice, node label, etc parameters?
2, The way you have accessed the referenced variable i.e. binding.variables.get(<parameter>) ? Is it always the same for all the parameters mentioned above by me?

Sorry for bothering too much, but, this is a real life saver plugin designed by you two :-)

Thanks,
Alok

Bruno P. Kinoshita

unread,
May 19, 2014, 1:20:11 PM5/19/14
to jenkin...@googlegroups.com
Hi

> 1. Does this work only with the choice parameter? OR it can be used with the extended choice, extensible choice, node label, etc parameters?

I have tested it with the choice parameter and the parameters from dynamic parameter plug-in. It shouldn't be had to include other parameters, but it isn't very elegant. The way it works, basically, is by navigating through Jenkins DOM (that is likely to be stable, specially with the new selenium tests that are being written) and extracting ${name}=${value}.

Give it a shot. If it doesn't work, file an issue at https://github.com/biouno/uno-choice-plugin/issues, provide as much info as possible (examples, use cases, code snippets, screen shots, etc) and we'll try our best to fix it for you. Or you can send a pull request as well ;)

> 2, The way you have accessed the referenced variable i.e. binding.variables.get(<parameter>) ? Is it always the same for all the parameters mentioned above by me?

Yes, though if for example binding.variables.get("versionNumber") is not null, then you can treat it as a normal variable in your scripts (i.e.: artifactFinalName = "myjar" + versionNumber). 

>Sorry for bothering too much, but, this is a real life saver plugin designed by you two :-) 

Never bothers at all, the more users/questions like these, the better the plug-in will be :-) 

Thank you!
Bruno


Sent: Monday, May 19, 2014 2:03 PM

Ioannis Moutsatsos

unread,
May 19, 2014, 2:59:15 PM5/19/14
to jenkin...@googlegroups.com
Hi Alok;

Most importantly reference parameters can be other uno-choice parameter values. If you think about it, dynamic parameter, extended choice, extensible choice and choice are all functional subsets of uno-choice.
Feedback is greatly appreciated!!... so no bother at all!

Best regards
ioannis
Reply all
Reply to author
Forward
0 new messages