Jenkins Master and Slave Concept
A Jenkins master comes with the basic installation of Jenkins, and in this configuration, the master handles all the tasks for your build system.
You may also enjoy: Getting Started With Jenkins: The Ultimate Guide
If you are working on multiple projects you may run multiple jobs on each and every project. Some projects need to run on some particular nodes, and in this process, we need to configure slaves. Jenkins slaves connect to the Jenkins master using the Java Network Launch Protocol.
Jenkins Master and Slave Architecture
The Jenkins master acts to schedule the jobs and assign slaves and send builds to slaves to execute the jobs.
It will also monitor the slave state (offline or online) and getting back the build result responses from slaves and the display build results on the console output. The workload of building jobs is delegated to multiple slaves.
Steps to Configure Jenkins Master and Slave Nodes
- Click on Manage Jenkins in the left corner on the Jenkins dashboard.
- Click on Manage Nodes.
- Select New Node and enter the name of the node in the Node Name field.
- Select Permanent Agent and click the OK button. Initially, you will get only one option, "Permanent Agent." Once you have one or more slaves you will get the "Copy Existing Node" option.
- Enter the required information.
Some required fields include:
6. Enter the Hostname in the Host field.
7. Select the Add button to add credentials. and click Jenkins.
8. Enter Username, Password, ID, and Description.
9. Select the dropdown menu to add credentials in the Credentials field.
10. Select the next dropdown to add the Host Key Verification Strategy under Non verifying Verification Strategy.
11. Select Keep this agent online as much as possible in the Availability field.
12. Click the Save button.
Creating a Freestyle Project and Running on The Slave Machine
- Click on Save and it will redirect to job's view page
- On the left pane, click the Build Now button to execute your Pipeline.
- We can verify the history of the executed build under the Build History by clicking the build number.
- Click on the build number and select Console Output. Here you can see the executed job in the remote host and output.
Creating a Pipeline and Running on The Slave Machine
- Click New Item in the top left corner on the dashboard.
- Enter the name of your project in the Enter an item name field, and select the Pipeline project, and click OK button.
- Enter Description (optional).
- Go to the Pipeline section, make sure the Definition field has the Pipeline script option selected.
- Copy and paste the following declarative Pipeline script into a script field.
6. Click on Save, it will redirect to the Pipeline view page.
7. On the left pane, click the Build Now button to execute your Pipeline.
8. After Pipeline execution is completed, the Pipeline view will be as shown below.
9. We can verify the history of executed build under the Build History by clicking the build number.
10. Click on build number and select Console Output. Here you can see that the pipeline ran on a slave machine.
0 Comments
Post a Comment