Jenkins Master / Slave Setup

We've been using a mix of Ant and Robocopy scripts to deploy our apps. While it works it requires some technical skills, and in some instances logging into remote servers.

I wanted to develop a process where our QA person (who is non-technical) could easily deploy and move code around for testing.

Enter Jenkins.

I won't go into setting up Jenkins since that is well documented and fairly straightforward.

When I first starting laying out this process I wanted to keep things fairly similar to the way they worked currently only replacing the manual steps with automated ones. But we're also using Git which I throught I could take advantage of...

First question - how can the Jenkins server talk to another server where I needed to run code?

My initial thought was to simply SSH between the two boxes but then I started reading about Jenkins master and slaves. Normally this mode is used to off load tests/jobs from the master to the slave to free up resources or for long running tests. But they can also be used for easy remote access to additional resources. In my case I'm on Windows, so SSH is not natively available. But I can connect via Java Web Start (JNLP) from my master to my slave.

The process to get things setup is easy:

First we need to create a new 'node' on our 'master' Jenkins server.

  1. Login to Jenkins
  2. Click Manage Jenkins
  3. Click Manage Nodes
  4. Click New Node
  5. Provide a Node name (or copy an existing node and modify) (I try to use server names for identification)
  6. Select Dumb Slave
  7. Click OK

Jenkins Node

  1. Provide a description
  2. Set remote root directory. This is the directory on the slave that Jenkins will use for it's workspace
  3. Set label for identification (again I used the Windows server name for easy identification)
  4. Usage - set to Only build jobs with label restrictions matching this node
  5. Launch method - Launch slave agents via Java Web Start
  6. Availabiltiy - default
  7. Set any environment or tool locations (if needed)

Jenkins Node

Now we need to access the remote box and setup the 'slave'. Note - the slave machine will need to have a current JAVA install.

Jenkins Slave

  1. First setup the root directory which you specified when create the new node on the master. In my case I create C:\Jenkins on my slave.
  2. (on the Master - select the new node you just created from the Node list)
  3. Copy the URL provided (ie: http://your.master.com/computer/yourSlaveName/)
  4. Log in to remote machine and visit this URL from the slave you wish to configure
  5. Click the Launch button
  6. Java will ask if you want to run this application - say yes.
  7. Once connected the Jenkins slave agent window will display a File menu
  8. Click File > Install as a service
  9. Select OK to install service

Now the slave will be setup to start as a Windows service so if the machine is rebooted you can re-connect as a slave.

Once installed you should return to Master Jenkins server and check on Node status.

It should now say "Connected via JNLP agent."

In my next point we'll configure a new job to use this remote slave node.