Setting up Agent Nodes via SSH in Jenkins
1. Introduction
Jenkins is an open-source automation server widely used for continuous integration and continuous delivery (CI/CD). Setting up agent nodes via SSH allows Jenkins to distribute workloads across multiple servers, improving efficiency and scalability.
2. Prerequisites
Before setting up agent nodes, ensure that you have:
- Access to the Jenkins master server.
- SSH access to the agent nodes.
- Java installed on all agent nodes.
- Jenkins agent jar file (usually named
agent.jar
).
3. Step-by-Step Setup
Follow these steps to set up Jenkins agent nodes via SSH:
-
Open the Jenkins dashboard and navigate to Manage Jenkins.
-
Click on Manage Nodes and Clouds.
-
Select New Node, enter a name for your agent, and choose Permanent Agent.
-
Configure the following details:
- Remote root directory: Specify where Jenkins will store files on the agent.
- Labels: Assign labels to categorize the agent.
- Usage: Choose how Jenkins should use this agent.
-
Scroll down to the Launch method section and select Launch agents via SSH.
Fill in the following fields:
- Host: The IP address or hostname of the agent.
- Credentials: Add the SSH credentials for the agent.
- Java Path: Specify the path to the Java executable if not in the default location.
-
Click Save to create the agent.
-
Test the connection by clicking on the agent name in the node list and selecting Launch agent.
4. Common Issues
While setting up agent nodes, you may encounter the following issues:
- Authentication Failure: Ensure the SSH credentials are correct.
- Firewall Issues: Check that the necessary ports (default is 22 for SSH) are open.
- Java Not Found: Verify the Java installation on the agent node.
5. FAQ
What is the purpose of agent nodes in Jenkins?
Agent nodes allow Jenkins to distribute work across multiple servers, which helps in building, testing, and deploying applications in parallel.
Can I use Windows machines as Jenkins agents?
Yes, Jenkins supports Windows machines as agents. You will need to ensure that you have the appropriate setup, including SSH and Java installed.
How do I check the status of my agent nodes?
You can check the status of your agent nodes in the Jenkins dashboard under Manage Nodes and Clouds.