You are currently viewing Jenkins Distributed Build (Master-Slave Configuration)

Jenkins Distributed Build (Master-Slave Configuration)

Jenkins distributed build (master-slave configuration)

Hello Everyone

Welcome to CloudAffaire and this is Debjeet.

In the last blog post, we have discussed how to install Jenkins in AWS EC2 instance.

In this blog post, we will discuss how to add additional nodes (slaves) in your Jenkins system to make a distributed build architecture.

It is pretty common when starting with Jenkins to have a single server which runs the master and all builds, however, Jenkins architecture is fundamental “Master+Agent”. The master is designed to do co-ordination and provide the GUI and API endpoints, and the Agents are designed to perform the work. The reason being that workloads are often best “farmed out” to distributed servers. This may be for scale, or to provide different tools, or build on different target platforms. Another common reason for remote agents is to enact deployments into secured environments

A “master” operating by itself is the basic installation of Jenkins and in this configuration, the master handles all tasks for your build system. In most cases installing an agent doesn’t change the behavior of the master. It will serve all HTTP requests, and it can still build projects on its own. Once you install a few agents you might find yourself removing the executors on the master in order to free up master resources (allowing it to concentrate resources on managing your build environment) but this is not a necessary step. If you start to use Jenkins a lot with just a master you will most likely find that you will run out of resources (memory, CPU, etc.). At this point, you can either upgrade your master or you can setup agents to pick up the load. As mentioned above you might also need several different environments to test your builds. In this case, using an agent to represent each of your required environments is almost a must.

An agent is a computer that is set up to offload build projects from the master and once setup this distribution of tasks is fairly automatic. The exact delegation behavior depends on the configuration of each project; some projects may choose to “stick” to a particular machine for a build, while others may choose to roam freely between agents. For people accessing your Jenkins system via the integrated website (http://yourjenkinsmaster:8080), things work mostly transparently. You can still browse JavaDoc, see test results, download build results from a master, without ever noticing that builds were done by agents. In other words, the master becomes a sort of “portal” to the entire build farm.

Since each agent runs a separate program called an “agent” there is no need to install the full Jenkins (package or compiled binaries) on an agent. There are various ways to start agents, but in the end, the agent and Jenkins master need to establish a bi-directional communication link (for example a TCP/IP socket) in order to operate.

Next, we are going to create a Jenkins distributed build configuration.

Jenkins master-slave configuration demo:

Master node configuration:

Note: You can follow the previous blog for post-installation configuration part.

Slave node configuration:

Add nodes in your Jenkins master configuration:

Login to your Jenkins UI and click ‘Manage Jenkins’.

Jenkins Distributed Build (Master-Slave Configuration)

Click ‘Manage Nodes’.

Jenkins Distributed Build (Master-Slave Configuration)

Click ‘New Node’ to add a new node.

Jenkins Distributed Build (Master-Slave Configuration)

Give a name to the node and select ‘Permanent Agent’. Click ‘OK’.

Jenkins Distributed Build (Master-Slave Configuration)

Provide slave node configuration details

Jenkins Distributed Build (Master-Slave Configuration)

Jenkins Distributed Build (Master-Slave Configuration)

Perform the same steps to add the other slave.

We have successfully added to slave nodes in our master Jenkins configuration.

Jenkins Distributed Build (Master-Slave Configuration)

You can test your target nodes by providing the label for your target node.

Jenkins Distributed Build (Master-Slave Configuration)

Hope you have enjoyed this article. To get more details on Jenkins, please refer to Jenkins documentation.