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

  1. Go to Manage Jenkins > Nodes and Clouds.
  2. Click New Node and configure the agent.
  3. Set labels for job routing.
  4. Choose a launch method such as SSH or JNLP.
  5. 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.