Jenkins Master Slave Configuration
Jenkins is an awesome Continuous Integration tool which allows you to add multiple slaves as per your project requirement to a central Master server.
In distributed environment, we need different machines for different purposes. For example, we may need machine1(Ubuntu) to run some process and machine2(CentOS) to run some other process. For such distribution, Jenkins Master Slave configuration comes to the rescue.
Let us consider an example to have better understanding about Master Slave configuration in Jenkins.
Considering Machine1 as a master where we deployed Jenkins set up.
- Go to url http://localhost:8080 in your browser, if Jenkins runs on localhost. Login using your credentials and click on Manage Jenkins option.
- Then click on the option Manage Nodes.
- Click on the option New Node in the left menu.
- Provide a name for your slave node. For this example, we have named our slave machine as Slave1. Check the option Permanent Agent, and click on OK.
- After Clicking OK, following configuration page will appear for machine Slave1.
Values for following configurations must be mentioned for setting up the slave machine:
- Description: The purpose of Node.
- # of executors: The maximum number of concurrent build that Jenkins may perform on this agent.
- Remote root directory: The path or directory of the agent machine(example: complete-path/slave1).
- Launch Method: Select Launch agent via Java Web Start. If you fail to find this option, go to Manage Jenkins → Configure Global Security and make sure that radio button Random is selected for TCP port for JNLP agents and Enable Slave → Master Access Control is checked.
- After selecting Launch Method as Launch agent via Java Web Start, save changes. Following page will appear and then Logout of Jenkins.
Note: Make sure in Manage Jenkins → Configure System, in the field Jenkins URL provide machine name instead of localhost (If not changed then it will consider the name as localhost for all agents while making JNLP and will bound to create error.
- Now, Login Jenkins Slave machine. Go to, Manage Jenkins → Manage Nodes, we will find our created Node Slave1.
- Click on it and you will see the following screen:
- Then click on Launch, a file named slave-agent.jnlp will be downloaded. Run the slave-agent.jnlp by double clicking on it. Following pop up will appear,
Click on Run
- A new popup window will appear with the message Connected.
- To install the slave agent as a window service, click on the File menu option and choose the option Install as a service.
- Now, check the browser, you will find that, Agent Slave1 is connected via JNLP agent.