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.
- Login to Jenkins
- Click Manage Jenkins
- Click Manage Nodes
- Click New Node
- Provide a Node name (or copy an existing node and modify) (I try to use server names for identification)
- Select Dumb Slave
- Click OK
- Provide a description
- Set remote root directory. This is the directory on the slave that Jenkins will use for it’s workspace
- Set label for identification (again I used the Windows server name for easy identification)
- Usage - set to Only build jobs with label restrictions matching this node
- Launch method - Launch slave agents via Java Web Start
- Availabiltiy - default
- Set any environment or tool locations (if needed)
Now we need to access the remote box and setup the ‘slave’. Note - the slave machine will need to have a current JAVA install.
- 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.
- (on the Master - select the new node you just created from the Node list)
- Copy the URL provided (ie: http://your.master.com/computer/yourSlaveName/)
- Log in to remote machine and visit this URL from the slave you wish to configure
- Click the Launch button
- Java will ask if you want to run this application - say yes.
- Once connected the Jenkins slave agent window will display a File menu
- Click File > Install as a service
- 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.