3

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.

Community
  • 1
  • 1
cp5
  • 1,087
  • 6
  • 26
  • 58

2 Answers2

3

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.

Zloj
  • 2,235
  • 2
  • 18
  • 28
  • 1
    Not what I want. This allows you to create a node parameter. But if I run a Job it will also execute on that node. I still want to the job to be executed on the master but I need to know the name of the selected node. – cp5 Aug 10 '15 at 12:22
  • You would need some kind of a node scheduler plugin that actually doesn't utilize any of the nodes from Jenkins point of view, is that correct? – Zloj Aug 10 '15 at 13:29
  • I have a MVN SOAP project that executes tests on a server. The SOAP project needs to know what server to run on. Hence I have the ability to target our DEV TEST and LIVE environment. What I am trying to do is just to have some selection list a project can use to choose from the node list. (we already make use of nodes for deployments). If I can get the node (or server name) into a variable I can pass this to the MVN project which will pass it to the SOAP project to execute on. – cp5 Aug 10 '15 at 17:20
0

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

Yann Delanoe
  • 164
  • 8