Reputation: 1219
I have a problems with Hudson because my job needs two params for build the first specifies the environment and can be one of DEV, QA, PROD, and the second is a specific server, this parameter depends on the first one.
By example if I chose environment DEV, the second parameter can be only DEV1,DEV2, MAQ1 . I don't have an idea if a plugin with this functionality exists or I need to make something with groovy. I do not know please help me.
Thank you
Upvotes: 15
Views: 39443
Reputation: 298
For all of you who stumble upon the same kind of problem (like I did). There is a fairly new Jenkins plugin available that does exactly what is desired here: display a dependent set of drop-downs, updating dependent boxes when a main box changes selection.
For your job you just need to follow the following steps:
The "multiselect parameter plugin" can be installed from Jenkins plugin management, the documentation is available on its Jenkins Plugin page.
H,Environment,Machine
V,SELECTED_ENVIRONMENT,SELECTED_MACHINE
T,Development,
C,DEV,DEV1
T,Development,
C,DEV,DEV2
T,Quality Assurance,
C,QA,QA1
T,Quality Assurance,
C,QA,QA2
T,Quality Assurance,
C,QA,QA3
T,Production,
C,PROD,Machine1
T,Production,
C,PROD,Machine2
When you run "build with parameters" in your job, the following boxes are displayed for selection:
In your build script you can simply use the configured environment variables SELECTED_ENVIRONMENT
and SELECTED_MACHINE
, which contain the selected values from both select boxes. The "human readable names" configured in T
-prefixes rows of CSV configuration are only displayed in select boxes, you still get the technical names like DEV
and PROD
passed into the environment variables.
Upvotes: 3
Reputation: 413
Try Active Choices Plugin. It is the second name of Uno-Choice plugin, but it is located in official Jenkins repository and does not require UpdateSites Manager plugin. (Both plugins have the same author). Plugin has a great documentation with examples (and gif-demonstration) on the plugin's description page.
Upvotes: 20
Reputation: 8420
A good plugin (requires you to have the UpdateSites Manager plugin and register the biouno update site) is the uno-choice plugin ( and friends).
The Uno-Choice Cascade Dynamic Parameter Plugin plugin allows for not only more than two levels of dependencies, but can generate dynamic content for the parameters which depend on previous input using either scriptler or inline groovy.
This is certainly much more capable than the previous answers.
Upvotes: 12
Reputation: 16305
I ran into similar problems. I have a parameter for the environment Dev1, Dev2, ..... and a second one for the server where I need to run the job. I can compute the second from the first, but then the job is already running and I can't move it to another server anymore.
So I ended up having the two parameters with all possible choices and teaching the users to only choose the valid combinations. I can test during script execution whether the combination is valid. I also put a small html table in the comment of one of the parameters which contains valid combinations.
In your case, can you compute the value of the first parameter from the values of the second parameters? Then you would be able to compute (if still necessary) the value of the first parameter, write it to a temporary properties file and load it with the EnvInject plugin in a later build step.
Upvotes: 0
Reputation: 3817
It appears that Jenkins loads the list of parameters to select when you open the "build project" page. There's no callback happening when selecting a parameter either.
In that case it will be difficult to restrict the second parameter based on the first one without javascript and a custom plugin.
I also looked at those:
I would ask the jenkins user list for more information.
Upvotes: 4
Reputation: 2070
You can try the EnvInject Plugin.
First you put the first parameter into a settings file.Then the plugin can read from the file .Step two,generate the second parameter with your own script.
Upvotes: 0