How to Add Slave Node in Jenkins: Step-by-Step Guide
To add a
slave node in Jenkins, go to Manage Jenkins > Manage Nodes and Clouds > New Node, enter a name, select Permanent Agent, and configure the node details like remote root directory and launch method. Then save and connect the slave to start running jobs on it.Syntax
Adding a slave node in Jenkins involves these key steps:
- Node Name: Unique name for the slave node.
- Node Type: Usually
Permanent Agentfor a fixed slave. - Remote Root Directory: Directory on the slave machine where Jenkins stores files.
- Launch Method: How Jenkins connects to the slave (e.g., via SSH or JNLP).
- Labels: Tags to group or select nodes for jobs.
jenkins
Manage Jenkins > Manage Nodes and Clouds > New Node - Enter Node Name - Select Permanent Agent - Configure Remote Root Directory - Choose Launch Method (e.g., Launch agent via SSH) - Save and connect
Example
This example shows how to add a slave node named build-slave-1 using SSH launch method.
jenkins
1. Go to Jenkins Dashboard > Manage Jenkins > Manage Nodes and Clouds 2. Click <New Node> 3. Enter <build-slave-1> as the node name 4. Select <Permanent Agent> and click OK 5. Set Remote root directory to <C:\\jenkins> (Windows) or <~/jenkins> (Linux) 6. Under Launch method, select <Launch agents via SSH> 7. Enter the slave machine's hostname or IP, credentials, and port 8. Save the configuration 9. Jenkins will connect and show the node as online
Output
Node 'build-slave-1' appears online and ready to run jobs.
Common Pitfalls
- Incorrect SSH credentials: Jenkins cannot connect if username or key is wrong.
- Firewall blocking ports: Ensure the slave machine allows Jenkins to connect on the SSH port.
- Wrong remote root directory: Directory must exist and Jenkins user must have permissions.
- Slave agent not running: For JNLP launch, the agent must be started manually or via a service.
jenkins
Wrong way: - Using wrong SSH username or password - Setting remote root directory to a non-existent folder Right way: - Verify SSH credentials before saving - Create and set correct permissions on remote root directory - Check network connectivity and firewall rules
Quick Reference
| Step | Description |
|---|---|
| Manage Jenkins > Manage Nodes and Clouds | Access node management |
| New Node | Create a new slave node |
| Node Name | Unique identifier for the slave |
| Permanent Agent | Select node type |
| Remote Root Directory | Directory on slave machine for Jenkins files |
| Launch Method | How Jenkins connects (SSH, JNLP) |
| Save | Apply and connect the slave node |
Key Takeaways
Add a slave node via Manage Jenkins > Manage Nodes and Clouds > New Node.
Configure remote root directory and launch method correctly for connection.
Use valid SSH credentials and ensure network access for SSH launch.
Check that the slave machine has the required directory and permissions.
Verify the slave node status in Jenkins dashboard after adding.