cp5
cp5

Reputation: 1133

How to select a node name as a parameter in jenkins using a selection list of some sort

I need to know if there is a plugin of some sort that you can select a node from a jenkins job and use that node name as a parameter to be passed to a Windows batch command

I have played with the Configuration Matrix using an Elastic-Axis or Slaves (Screenshot below where you can tick the names) plugins

enter image description here

But these all go and execute the Windows batch command on that selected node.

I don't want to execute it on that server but rather on the main node and only pass the value of the slave/label to the windows batch command.

I were able to do it as described here but that involves 2 jobs and a groovy scripts to interrogate the slaves/nodes config. Write it to a properties file and pass the properties file to the next job.

Jenkins: How to get node name from label to use as a parameter

I need to do about 30 jobs of these and hence would like to try to do all in one job - if I used my solution in the link above, 30 jobs would double in 60 jobs and maintenance would be kind of a nightmare.

I also would not like to have a string parameter and hard code the name of the slave/node as that will not ensure the use of only the available slaves/nodes but any server name can be entered and that would can be a problem where someone can mistype a server name for example pointing to a Production server instead of a test server.

Upvotes: 3

Views: 14974

Answers (2)

Yann Delanoe
Yann Delanoe

Reputation: 174

You can use the active choice parameter plugin https://plugins.jenkins.io/uno-choice/ with a little groovy script to list node names in a parameter selection box.

enter image description here

Upvotes: 1

Ivan
Ivan

Reputation: 2340

https://wiki.jenkins-ci.org/display/JENKINS/NodeLabel+Parameter+Plugin After installing this plugin you will have an option to add a Node parameter to Jenkins job. It will have a list of all slaves available on current master.

Upvotes: 3

Related Questions