How to configure Jenkins agents?
· Category: DevOps & CI/CD
Short answer
Jenkins agents are machines that execute pipeline steps. They can be permanent VMs, cloud instances, or containers. Configure them in Manage Jenkins > Nodes and Clouds.
Steps
- Go to Manage Jenkins > Nodes and Clouds.
- Click New Node and configure the agent.
- Set labels for job routing.
- Choose a launch method such as SSH or JNLP.
- Save and connect the agent.
Example
pipeline {
agent {
label 'linux && docker'
}
stages {
stage('Build') {
steps {
sh 'docker build -t myapp .'
}
}
}
}
Tips
- Use labels to group agents by capability.
- Use cloud plugins for dynamic agent provisioning.
- Set executor counts based on agent capacity.
Common issues
- Agents may disconnect due to network issues.
- Mismatched tool versions between agents cause failures.
- Insufficient disk space on agents breaks builds.