23

I recently inherited a Jenkins-driven Java project where the primary developer just upped and quit. He had deployed the Jenkins WAR to a Tomcat instance on a virtual server, and that is what was considered to be the "build server".

This build server had a slave configured for building and deploying to myserver.example.com, another virtual server. Over the weekend, the systems staff retired the physical server that the myserver.example.com virtual lived on, producing the following exception for any Jenkins job configured to deploy to that slave:

enter image description here

When I click on the "See log for more details" link I see the following console output:

[03/18/13 08:13:31] [SSH] Opening SSH connection to myserver.example.com:22.
java.io.IOException: There was a problem while connecting to myserver.example.com:22
    at com.trilead.ssh2.Connection.connect(Connection.java:755)
    at com.trilead.ssh2.Connection.connect(Connection.java:546)
    at hudson.plugins.sshslaves.SSHLauncher.openConnection(SSHLauncher.java:650)
    at hudson.plugins.sshslaves.SSHLauncher.launch(SSHLauncher.java:283)
    at hudson.slaves.SlaveComputer$1.call(SlaveComputer.java:200)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
    at java.util.concurrent.FutureTask.run(FutureTask.java:138)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
    at java.lang.Thread.run(Thread.java:662)
Caused by: java.net.NoRouteToHostException: No route to host
    at java.net.PlainSocketImpl.socketConnect(Native Method)
    at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:351)
    at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:213)
    at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:200)
    at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
    at java.net.Socket.connect(Socket.java:529)
    at com.trilead.ssh2.transport.TransportManager.establishConnection(TransportManager.java:342)
    at com.trilead.ssh2.transport.TransportManager.initialize(TransportManager.java:450)
    at com.trilead.ssh2.Connection.connect(Connection.java:699)
... 9 more
[03/18/13 08:13:34] [SSH] Connection closed.

This makes sense, since the slave (the myserver.example.com virtual) is offline. However, having no real previous experience with Jenkins, I'm not sure of what the proper steps are for configuring the Jenkins master to build/deploy these jobs to a new slave, and how to set up the new slave. For instance, do I need to install anything on the new slave, or do any kind of setup/config? Thanks in advance!

IAmYourFaja
  • 55,468
  • 181
  • 466
  • 756

2 Answers2

36

Adding a slave in Jenkins is pretty simple. Basically, if you are using a unix slave, you need SSH access to the machine. You also need to have the Jenkins SSH Slaves plugin installed. Once you have that, go to the Manage Jenkins option on your Master and choose Manage Nodes.

The steps are then:

  1. Click New Node
  2. Select Dumb Slave and give it a name (symbolic, doesn't need to be the domain name, that comes later)
  3. Click OK and proceed to the configuration page
  4. Fill in the # of executors with the number of simultaneous processes you want to run on that node (usually not more than the number of allocated CPU cores)
  5. Fill in the Remote FS Root with the full path to where you want Jenkins to store its working files
  6. Optionally add Labels if you are using those in your system (not necessary in many cases, but your Projects may require nodes have certain labels to be in the pool of executors for specific jobs)
  7. Select Launch slave agents on Unix machines via SSH under Launch Method (if not already selected)
  8. Put the fully-qualified domain name in the Host field which appears under the Launch Method line

There are some assumptions about the tools that are installed on the slave. If you have specialized tools, you may need to install them separately (or look at plugins that handle moving tools over immediately prior to execution). However, if your nodes are built off of a template which has all of your build tools on them (java, ant, etc in your case probably), then this will be all you need to do to get things going.

gaige
  • 17,263
  • 6
  • 57
  • 68
  • I have deployed jenkins.war file on tomcat which runs on my linux machine.I needed to setup slave on Windows machine.But I am unable to do so.The Jenkins Slave window on slave shows trying to connect but doesnt get connected.Please help what exactly i need to do in the 7th step mentioned above – jeevan s Nov 04 '15 at 12:44
  • I tried running jenkins.war without tomcat and it was able to setup slave on windows machine.But i need to have jenkins to run on Tomcat.Please help – jeevan s Nov 04 '15 at 12:46
  • Just went and added the port number in Configure Global Security->Enable Security->TCP port for JNLP slave agents to the port number – jeevan s Nov 04 '15 at 13:23
  • @jeevans you should probably look for another answer or create your own question for your specific circumstances. My comments, as indicated above, were for UNIX implementations of slaaves started by SSH and don't apply to Tomcat-hosted slaves on Windows. Cheers. – gaige Nov 04 '15 at 14:03
  • @gaige this is a great walkthrough. can you organize with context? where are these steps run? on the slave server or the master server? i'm also not seeing the host field – tarabyte Apr 05 '16 at 22:53
  • 1
    @tarabyte I'll see if I can make a couple of changes to clarify this. These steps are to be taken on the master server. For the Slave Server, you shouldn't need to stall the GUI before launching the agent via the Manage Nodes pane. As for the Host field, it appears under the Launch Method after you select SSH (which on my machine was the default). – gaige Apr 06 '16 at 17:10
0

I encountered the very same problem you did, in my case this was because I had not installed an ssh server on Ubuntu.

ChrisAdkin
  • 1,236
  • 1
  • 16
  • 31
  • How did you ensure that an ssh server was installed? – fuzzi May 31 '18 at 13:16
  • If my memory serves me correctly I installed the open ssh package: https://help.ubuntu.com/lts/serverguide/openssh-server.html.en – ChrisAdkin Jun 01 '18 at 10:06
  • 1
    If my memory serves me correctly I installed the open ssh package: https://help.ubuntu.com/lts/serverguide/openssh-server.html.en – ChrisAdkin Jun 01 '18 at 10:06
  • You also need to use a minimum version of 1.7 of the Java sdk, otherwise if you are using 1.6 this can throw errors which might make it appear that ssh is not working. – ChrisAdkin Jun 01 '18 at 22:15