Part II: Add a Jenkins Slave to Jenkins Master

Image for post
Image for post
Jenkins Distributed Architecture

In the previous post, we deal with how to setup Jenkins Server on Docker container. If you did not see please have look here. Now our intension is here add a running Jenkins server a slave(worker) node to parallelize jobs. Jenkins provides a distributed build option via the so-called Slave or Worker. There is a bunch of benefits to using slaves. Some of them

  • Scalability
  • Building for the different target platform (i.e for different binaries for different architectures)
  • For secure deployment process and so on.

So let’s start configuring the slave node. I will use my Linux machine as a slave node but you may use a virtual box or another docker container as a slave as well. My Jenkins Master is running on a docker container and dashboard looks:

Image for post
Image for post
Jenkins-Master dashboard
  1. Step: Manage Jenkins → Configure System → Manage Nodes and Clouds
Image for post
Image for post
System Configuration

2. Step: Manage Nodes and Clouds → New Node

Image for post
Image for post

3. Step: New Node →

Image for post
Image for post

Now on give a name your slave, I will call as myslave and click the radio button below where Permanent Agent has written.

4. Step: OK → give essential configuration of the slave’s parameters

Image for post
Image for post

Briefly explain all parameters

Name: is you custom name for you Slave node
Description: you can give also any short description
#of executors: number of instance
Remote root directory: the path on your slave where file saved. Create a directory on home dir of slave. I created a called jenkins.
Labels: when you want to manage many of slave i.e if you run linux on your slave. you may give linux as label and then manage them as group by using only label
Usage: You can choise an option that you need
Launch method: Specify how to start the slave node. I did choice Launch agents via ssh
Host: give here IP-Address of the slave
Credential: credential to login slave machine.
Host Key Verification Strategy: how to verify host key, listed many option. Please choice Manual Trusted Key Verification Strategy
Image for post
Image for post

5. Step: Credential is a step between actually. Enter username and password then add it.

# username and password of the slave machine
Username: celcin
Password: xxxxxxxxxx
Credentials

6. Step: If you provide all information then save it. You should see:

Image for post
Image for post

In case of any inconsistency checks the Logs on the left side of the dashboard.

Image for post
Image for post
logs

Now the slave or called agent is ready to run any job. Now let us create a simple job and run on slaves.

7. Step: Go to → Jenkins dashboard → New Item → give a name and choice Freestyle projects → OK

Image for post
Image for post

8. Step: On the next screen you have to specify where the job will be executed. Restrict where this project can be run. Check-in and give the Label that we gave our slaves. We set as slave_1

Image for post
Image for post

Now the specified jobs will be run on the slave! Happy coding!

Resources
* Jenkins Documentation
* Codebind

Computer Science And DevOps things :)

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store