How to set-up Master-Slave in Jenkins?
Pre-Conditions to configure Master & Slave configuration in Jenkins:
- Jenkins should be up & running in a local/remote server
- User should have admin access to configure Jenkins
Plug-ins to be installed in Jenkins:
Go to Jenkins --> Manage Jenkins --> Manage Plugins --> Available tab--> Search the below plugins & install them
- Node and Label parameter plugin
- Windows Slaves Plugin
- slave-status
- Multi slave config plugin
- built-on-column
- SSH Slaves plugin
Steps before set-up:
- Go to Jenkins --> Manage Jenkins --> Configure Global Security
- In Agents section, observe the "TCP port for JNLP agents" section
- "TCP port for JNLP agents" should be selected to Fixed with a random number entered in the text-box beside it.
- Click on "Agent Protocols" button
- select the checkbox - "Java Web Start Agent Protocol/4 (TLS encryption)"
- Click on Apply button in the bottom of the Jenkins page and then click on Save button beside it.
Agents
| |||||||||||||||||||||||||||||||||
| TCP port for JNLP agents | |||||||||||||||||||||||||||||||||
| Agent protocols |
| ||||||||||||||||||||||||||||||||
Steps to Set-up:
- Go to Jenkins --> Manage Jenkins --> Manage Nodes
- By Default, master is found in row 1 of Manage Nodes page in Jenkins
- Click on "New Node" on the left menu bar of Manage Nodes page in Jenkins
- Add a node name for slave
- Add a number 2 in "# of Executors" field --> This number can vary based on the number of cores your slave contains. Number can be 2 for a dual-core machine & 4 for a Quad-core machine.
- Add a label to identify this slave machine by label name while configuring in Jobs
- In Usage field, select "Only build jobs with label expressions matching this node", so that we can run on this machine only when job is configured to run in this machine.
- In Launch Method field, select "Launch agent via Java Web Start", to install and connect master to slave via JNLP connection.
- In Availability field, select "Keep this agent online as much as possible"
- In Node properties, add the following environment variables: Name: BUILD_ID, Value: dontKillMe
- Click on Save
| |||||||||||||||||||||||||

