Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jenkins: How to show/hide string parameter fields, after checkbox is un/checked?

I need to create Jenkins job, which installs product.iso on defined machine. I have 2 options: latest.iso (path to it is already known) custom.iso (path have to be determined manually)

Best implementation would be for me a checkbox named: "install custom iso"

When user choose(check) this checkbox - two string parameter fields would appear below (for determine IP and PATH of custom iso.) When user unchecks this checkbox - these two string parameter fields disappear (and default latest.iso would be installed)

I've searched through many Jenkins plugins, but it seems, that none of them allows this kind of action, which is strange to me, because I think, that this type of action is frequently needed.

Is there any simple way to do it? Any help would be appreciated.

like image 245
Texx Avatar asked Oct 06 '16 09:10

Texx


1 Answers

I think this Plugin will help you to make your Parametarized build more dynamic.

The Active Choices plug-in provides additional Jenkins parameter types that can be rendered as user interface (UI) controls in job forms. It supports using system environment variables, global node properties, and you also have at least the Jenkins project in the Groovy context for Freestyle jobs at least.

Once the plugin is installed three new parameter types become available:

  1. Active Choices Parameter

  2. Active Choices Reactive Parameter

  3. Active Choices Reactive Reference Parameter

Active Choices parameters allow users to select value(s) for a job parameter. Parameter values can be:

a) dynamically generated (using Groovy or a Scriptler script)

b) dynamically updated based on other UI parameters

c) multi-valued (can have more than one value)

d) rendered with a variety of UI controls, including dynamic HTML.

For more clarification and examples, Please refer here: https://wiki.jenkins.io/display/JENKINS/Active+Choices+Plugin

like image 109
Ayushi Jain Avatar answered Sep 18 '22 12:09

Ayushi Jain