Part II: Add a Jenkins Slave to Jenkins Master
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:
- Step: Manage Jenkins → Configure System → Manage Nodes and Clouds
2. Step: Manage Nodes and Clouds → New Node
3. Step: New Node →
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
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
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
6. Step: If you provide all information then save it. You should see:
In case of any inconsistency checks the Logs on the left side of the dashboard.
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
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
Now the specified jobs will be run on the slave! Happy coding!
Resources
* Jenkins Documentation
* Codebind