In this guide we will explore how to add slaves (build nodes) to jenkins.
The Jenkins architecture is designed for distributed build environments. It allows us to use different environments for each build project balancing the workload among multiple agents running jobs in parallel. These build environments are what were refer to as the slaves.
The Jenkins controller is the orignal node in the Jenkins installation. The Jenkins controller administers the Jenkins agents and orchestrates their work, including scheduling jobs on agents and monitoring agents. Agents may be connected to the Jenkins controller using either local or cloud computers.
The agents require a Java installation and a network connection to the Jenkins controller.
Prerequisites
To add jenkins slave, you need the following:
- Jenkins server
- At least one other server to use as slave
On the slave server, ensure java is installed:
Install Java
Install java on your system. We will be using the openjdk version of java. In centos 8, to check what software provides the java command line, use the following command: dnf whatprovides java
|
|
We can see that it is provided by the java-1.8.0-openjdk-1:1.8.0.275.b01-1.el8_3.x86_64
. Install it using the command
|
|
After the installation is complete, check the installed java version.
|
|
Add New User
Now we need to add a user that the jenkins master will use to connect to the slaves. We will create a user called jenkins
.
Run the command below.
|
|
Generate ssh key to use
Use this command to generate ssh key
|
|
Copy the SSH Key to use
Upload the key generated to the slave.
|
|
Add New Slave Nodes
- On the Master Jenkins dashboard, click the Manage Jenkins; menu, and clickManage Nodes And Clouds.
- Click the New Node.
- Type the node name slave01, choose thepermanent agent, and click OK.
- Now type node information details.
- Description: slave01 node agent server
- Remote root directory: /home/jenkins/slave01
- Labels: slave01
- Launch method: Launch slave agent via SSH, type the host ip address 10.0.15.21, choose the authentication using Jenkins credential.
- Now click Save button and wait for the master server to connect to all agent nodes and launch the agent services.
Testing
To test this, create a job and on the Label Expression, specify the node such as slave01. Run the job.