3
votes

I'm using Jenkins (1.573) and Swarm plugin (2.0): https://wiki.jenkins-ci.org/display/JENKINS/Swarm+Plugin.

Downloaded the jar from http://maven.jenkins-ci.org/content/repositories/releases/org/jenkins-ci/plugins/swarm-client/2.0/

I have already installed the Plugin in Jenkins (master) and from one of the Linux machine (which I would like to use as a Slave) I downloaded the swarm client jar with dependencies 2.0 and ran the following command:

Note:
$p variable has the password stored in it.
One can use mode as normal (instead of exclusive).

$ java -jar swarm-client-2.0-jar-with-dependencies.jar -name "`hostname -a`_01" -fsroot "`pwd`/`hostname -a`_01" -master http://jenkins_server.yo.company.com:8081 -disableSslVerification -username c123456 -password $p -description "`hostname -a` " -executors 5 -labels "ANSIBLE_CENTOS CENTOS" -mode 'exclusive' -retry 3

Discovering Jenkins master
Dec 03, 2015 3:52:58 PM org.apache.commons.httpclient.HttpMethodBase getResponseBody
WARNING: Going to buffer response body of large or unknown size. Using getResponseBodyAsStream instead is recommended.
Attempting to connect to http://jenkins_server.yo.company.com:8081/ 1229493c-3bd5-4cf4-9210-3392089f2ee2 with ID 1893f0ea
Could not obtain CSRF crumb. Response code: 404
Dec 03, 2015 3:53:01 PM hudson.remoting.jnlp.Main createEngine
INFO: Setting up slave: jmeter01_01-1893f0ea
Dec 03, 2015 3:53:01 PM hudson.remoting.jnlp.Main$CuiListener <init>
INFO: Jenkins agent is running in headless mode.
Dec 03, 2015 3:53:01 PM hudson.remoting.jnlp.Main$CuiListener status
INFO: Locating server among [http://jenkins_server.tsh.thomson.com:8081/]
Dec 03, 2015 3:53:02 PM hudson.remoting.jnlp.Main$CuiListener status
INFO: Connecting to jenkins_server.tsh.thomson.com:53605
Dec 03, 2015 3:53:02 PM hudson.remoting.jnlp.Main$CuiListener status
INFO: Handshaking
Dec 03, 2015 3:53:02 PM hudson.remoting.jnlp.Main$CuiListener status
INFO: Connected

In Jenkins master, I'm seeing the slave is successfully created (using JLNP auth) but slave's name is little weird.

Instead of creating the slave name as the hostname (i.e. jmeter01 in my case or jmeter01.yo.company.com), it's suffixing the slave name with a RANDOM alphanumeric value. Sometimes as jmeter01_01-ee12355ec and sometimes, jmeter01_01-1893f0ea.

I would like the slave name to be just: jmeter01_01 or someserver_01 or someserver.fq.dn_01

What I may be giving wrong?

2
What makes this post eligible for a downvote? It's a valid question. If you have answer, please let me know.AKS

2 Answers

7
votes

Using option -disableClientsUniqueId in the command line solved it.

I think -name VALUE should be enough but it seems like they have taken the approach that the slave will be created each time (no matter what) and that's why they were suffixing the name with a Unique/Alphanumeric ID value to the slave name. Using the above property solved it (after I did more research and found that they introduced the fix in version 2.0).

Addition: To create Tool locations within the slave's configuration, I used -t Java=~/tools/jdk1.8.0_45 -t Gradle=~/tools/gradle-2.9 and the command gave me an error No tool 'Java' is defined on Jenkins.

javax.servlet.ServletException: java.lang.RuntimeException: No tool 'Java' is defined on Jenkins.

After researching, I found this is because in Jenkins Master (that I used), it's JDK Installations section (within Jenkins global settings) had this tool Name value set as "java".

Trying -t java=~/tools/jdk1.8.0_45 resolved the issue and now I can see (JDK) java tool with value ~/tools/jdk1.8.0_45 in the slave's configuration.

PS: There's no way to define ENVIRONMENTAL variables (like we usually define/see in a node/slave's configuration in Jenkins GUI) using swarm client jar (that's something one can enhance the Swarm plugin with this new feature).

0
votes

Templorary I resolved this issue with downgrade jenkins-swarm plugin version to 1.2