Jenkins – Slave Node Configuration

We will be learning here about the Jenkins Master node and Slave node and how we can set up a Slave node on a remote Linux server using a simple step-by-step method.


What is a Jenkins master node?

The Jenkins master node is wherever your Jenkins is installed and running.


What is a Jenkins Slave node?

Jenkins Slave is simply a java executable that runs on the remote machine. Jenkins Slaves can run on a variety of OS.

So, sometimes this single Jenkins master node is not enough to meet certain requirements. For example, we might need several different environments to test our builds. This cannot be done on your master node. For that, we need to create a slave node.

Another scenario can be when we want to build a larger or heavier project on your Jenkins. In this case, your Jenkins server cannot handle the load of the jobs. For this, we can create slave nodes that will help in distributing the load of the jobs.

Let’s learn how to create and configure the Jenkins Slave node using the SSH method (Linux).


Step 0. Prepare a Linux instance.

This Linux instance will be going to be Jenkins’s slave node. You can use a virtual machine of any cloud provider such as AWS, Azure, Linode, etc.

✔  Create a directory for Jenkins files and folders.



✔  Install Java8 or more on the server –

    ✔  sudo apt-get update

    ✔  sudo apt-get install openjdk-8-jdk

    ✔  java -version


Step 1. Creating a Jenkins Slave node.

✔  Go to Manage Jenkins and then click on Manage Nodes and Clouds (Mange Nodes in old versions).

✔  There will be a master node on which we are working.

✔  Click on the New Node.

✔  Give any name to your slave (ubuntu_slave) and check Permanent Agent.




Step 2. Configuring the Jenkins Slave node.

Note: You can read about all the fields of configuration by clicking on the Question mark icon on the right side of each field.




✔  Description: give an appropriate description of the slave.

✔  # of executors: no. of parallel jobs which this slave can handle.

✔  Remote root directory: the directory where you want to save all the Jenkins-related files.

✔  Labels: it is used to group several slave nodes into a logical group.

✔  Usage: this has two options –

    ✔  Use this node as much as possible: to use this node whenever possible.

    ✔  Only build jobs with label expressions matching this node: to use this node when the label mentioned in the above field matches in the job.

✔  Launch method: we will use the Launch slave agent via SSH

    ✔  Host: public IP of the slave server.

    ✔  Credentials: These steps are for an AWS server.

        ✔  Click on add and then on Jenkins.

        ✔  Kind: Select “SSH Username and private key”.

        ✔  ID: ubuntu_slave.

        ✔  Description: give a description.

        ✔  Username: give the server’s username. For eg. ubuntu

        ✔  Private Key: add the private key here by pasting the available .pem file.

✔  Click on Add button.




✔  Choose the credential that you have from the dropdown.

    ✔  Host Key Verification Strategy: select Manually trusted key Verification Strategy.

    ✔  Require manual verification of initial connection: leave this UNCHECKED.

✔  Availability: leave it as default.

✔  Click on the Save button.

For now, the slave agent is offline.




Step 3. Making the Slave Agent Available

✔  Click on the new slave.

✔  Click on the Launch agent button.

After some time, it will show, “Agent successfully connected and online”.

Now the agent is online.

Note: If get some error while launching, please check the path of Java on the slave server and modify it in the advanced field of the slave configuration.


Step 4. Test the Jenkins Slave.

✔  Create a freestyle Jenkins job.

✔  Check the Restrict where this project can be run option in the General section while configuring the job

✔  Now, you can see the name and label of the slave node. Choose the name for this example.




✔  Next, choose to execute a shell in the Build section and print something like:

    ✔  echo “This job is executed on Slave node…”

✔  Save the configuration.

✔  Build the job by clicking on Build now.

✔  Check the console output and you will see the job is being executed on the slave node that we created earlier.




On the Jenkins directory of the slave node, we can see that there are some directories and files got created by Jenkins.





We have learned how can we create and configure a Jenkins slave node using the SSH method. We have tested the slave node by creating a test job and that job built on the slave node remotely.