Has anyone tried a way to add or update an ENVIRONMENT variable in a Jenkins subordinate configuration using the Jenkins Rest / API or any other way.
Using the Jenkins Swarm plugin, I created a subordinate (it uses JLNP to connect to the Jenkins master), but the ENVIRONMENT variables (the box is not checked) and there are no ENVIRONMENT variables created by the Swarm client bank (by default). User can add manually if reqd, but I am looking for if there is a way to add / update ENV variables in slave.

I want to create several slave roms (where each subordinate has different tools with different values, i.e. slave01 JAVA_HOME = / path / jdk1.7.0.67 and other slave02 JAVA_HOME = / path / jdk1.8.0_45, etc. etc.).
I tried looking at http://javadoc.jenkins-ci.org/hudson/model/Node.html or http://javadoc.jenkins-ci.org/hudson/model/Slave.html or http: //javadoc.jenkins -ci.org/hudson/slaves/DumbSlave.html , but it does not provide any method / way to set the Node of ENV properties / variables. There is no setNodeProperties or anything like that (if this is the right method to set ENV variables / properties).
What I'm looking for is a way to add the following variables to the slave.

This post (from Villiam) reflects that someone was trying to do the groovy part to do the same, but I donβt see how he can set ENV variables using the same node creation / management API
Jenkins-CLI has the ability to run groovy scripts:
java -jar path/to/jenkins-cli.jar -s http://localhost:8080 groovy path/to/script
script:
import jenkins.model.* import hudson.model.* import hudson.slaves.* Jenkins.instance.addNode(new DumbSlave("test-script","test slave description","C:\\Jenkins","1",Node.Mode.NORMAL,"test-slave-label",new JNLPLauncher(),new RetentionStrategy.Always(),new LinkedList()))
(see docs for other options: http://javadoc.jenkins-ci.org/ )
You can also start the groovy interactive shell with
java -jar jenkins-cli.jar -s http://localhost:8080 groovysh
environment-variables jenkins jenkins-plugins master-slave
Arun sangal
source share