title: Jenkins: How to get node name from label to use as a parameter
body: <p>I need to give a server name to a maven build. During the maven build this server name will be used to make a call that server do some tests on that server.</p>
  
  <p>Our servers have jenkins slaves on them and is grouped using labels</p>
  
  <p>Example</p>
  
  <pre><code>Slaves/Node |  Label
  
  Server1     |  BackEndServers
  
  Server2     |  BackEndServers
  
  Server3     |  FrontEndServers
  
  Server4     |  FrontEndServers
  </code></pre>
  
  <p>With Elastic Axis plugin i can say run my Jenkins job on this Node Label (for example on BackEndServers) and the same project will be executed on both of the servers (Server1 &amp; Server2).</p>
  
  <p>In my case I cannot do this as maven is not installed on the BackEndServers where my code is running. But the maven build needs to know about the server names though.</p>
  
  <p>So is there a way how I can get the server names from a label and then run the same job multiple times passsing each servername to the maven build?</p>
  
  <p>Example</p>
  
  <ul>
  <li><p>Giving that I have the label 'BackEndServers' </p></li>
  <li><p>obtain a list of node names 'Server1,Server2' </p></li>
  <li>and run my job for each node name and pass a parameter to it</li>
  <li>aka </li>
  <li><ul>
  <li>Having Job (with parameter Server1)</li>
  </ul></li>
  <li><ul>
  <li>Having Job (with parameter Server2)</li>
  </ul></li>
  </ul>