title: Jenkins: configure slave node address dynamically using command or groovy script
body: <p>I have kinda ssh slave build jenkins setup. </p>
  
  <p>Jenkins server connect to  Mac slave thru ssh. build ios apps there. two remote nodes are configured in Jenkins connected to the Mac.
  The Mac has dhcp. </p>
  
  <p>Every time my mac starts I want to run a script that tell the Jenkin server to configure the node's IP address pointing to the dhcp address that the mac receives. Since its dhcp it changes always. </p>
  
  <p>Is possible to configure such? using shell script or perl ... </p>
  
  <pre><code>e.g. http://jenkins-server:8080/computer/mac-slave-enterprise/configure
  </code></pre>
  
  <p>is the node config url. If its possible to setup by sending host=10.1.2.100 &amp; Submit=Save or something like this?</p>
  
  <p>I found it is possible run Groovy script at </p>
  
  <pre><code>http://jenkins/script
  </code></pre>
  
  <p>or from mac command line or sh script,</p>
  
  <pre><code>$ curl -d "script=&lt;your_script_here&gt;" http://jenkins/script
  </code></pre>
  
  <p>I tried to get some info with this code but no luck, seems I have create SSLLauncher, but lost in how to grab a launcher things. There is no direct setHost or setLauncher thing. </p>
  
  <p>following the tutorial at,</p>
  
  <pre><code>https://wiki.jenkins-ci.org/display/JENKINS/Display+Information+About+Nodes
  </code></pre>
  
  <p>but cannot set the host address.</p>
  
  <pre><code>println("node desc launcher = " + aSlave.getComputer().getLauncher()); 
    //println("node desc launcher = " + aSlave.getComputer().getLauncher().setHost("10.11.51.70")); 
    println("node launcher host = " + aSlave.getComputer().getLauncher().getHost()); 
  
    hudson.plugins.sshslaves.SSHLauncher ssl = aSlave.getComputer().getLauncher(); 
    int port = ssl.getPort(); 
    String userName, password, privateKey; 
    userName = ssl.getUsername(); 
    password = ssl.getPassword(); 
    privateKey = ssl.getPrivatekey(); 
  
    println("user: "+userName + ", pwd: "+password + ", key: "+privateKey); 
  // all these values returns null. 
  </code></pre>