Home > Builds automation > Setting up slave machine for Hudson/Jenkins

Setting up slave machine for Hudson/Jenkins

Jenkins (renamed version of Hudson) is very powerful automation tool that enables you to create continuos integration or even continuos development on your project. If you plan to work on project in team and expected that time of project will be more than 1-2 month than you must spend some time and setup automation builds. Jenkins is one of the tools that provide with good quality web-interface for  automatic build. In this article I’ll talk about setup of remote build of your project.

What is remote build and why you may need it. Our project has a big scale so one large node on amazon is not enough for it. Setting up to different nodes was not easy (we have dependencies from 3rd party services and for each node we need to ask a new keys from this services). To solve this problem we decided to move all processes that require cpu time and a lot of memory to another node and run them on the separate node. Processes that have been moved to another node: build of client, running selenium, some monitoring tasks. I’ll provide an instruction below how to setup slave node for jenkins because it is not clear from documentation.

First of all you need to setup a slave machine. Here are steps how to do this (manual is for linux based servers):

  1. On slave machine generate ssh-key pair (ssh-keygen). You’ll have a 2 files: <your keyname> and <your keyname>.pub
  2. Add private key to the authorized keys to user which will be start slave. (add a string from <your keyname>.pub to the ~/.ssh/authorized_keys). More details about this steps you can find here.
  3. Move private key to the host machine in any way you can (ftp, mail, scp, etc) and put it to some location (e.g ~/jenkinsuser/.ssh/), make this file readable for jenkins user only.
  4.  Go to the Administration -> Manage Hudson -> Manage Nodes -> New Node
  5. Select Dumb Slave
  6. Provide number of executors equals the CPU number on slave computer or less.
  7. Provide some directory where slave will be held its temp info (for example, /var/jenkins/)
  8. Select Launch method: “Launch slave machines on Unix via ssh”
  9. Provide user and key in the fields.
  10. Provide all others options that you need.
  11. Click save and enjoy. In some minutes your slave node will be started.

Nothing hard till now? Isn’t it?

Ok. Now you have your slave up and running. Jenkins will try to keep it up as long as it can.

Here you can see all slave nodes you’ve setup. Remember the name of those here you want to create a task.

To run task on remote node you need to specify this node in the task details in the Restrict where this project can be build.

See screenshot for example:

After this setup this job will be run only on this slave node.

If you want to receive something after this job will finished you can select checkbox in Post-build actions “Build other projects” and create another project that will receive a data from your slave machine. Receiving command can be like this:

scp -i /Users/user/.ssh/key jenkinsuser@yourslavehost:path_to_file where_put_file

This is all you need to do to setup slave machine. Hope this will help you!

  1. carter
    August 17th, 2012 at 14:33 | #1

    Do you need the ssh slave plugin for this?

    • August 17th, 2012 at 17:41 | #2

      Yes, you need this plugin, but it is setup by default in every fresh Jenkins installation.
      Thank you, I’ll update the post with this info as prerequisite.

      • Anonymous
        October 3rd, 2012 at 09:43 | #3

        Actually no, it isn’t.

  1. No trackbacks yet.