Distributed Builds
As you add more jobs, the Jenkins master may become overloaded. Distributed builds allow you to offload job execution to agent nodes. Agents can be physical machines, VMs, or containers.
Why Distributed Builds?
- Scale horizontally – add more agents as needed.
- Isolate builds (different OS, tools, or environments).
- Prevent a single failing job from affecting others.
- Keep master lightweight (only UI and orchestration).
Adding an Agent (Node)
1. "Manage Jenkins" → "Nodes" → "New Node".
2. Give it a name, select "Permanent Agent".
3. Configure:
- Remote root directory (e.g.,
/home/jenkins/agent).- Labels (e.g.,
linux or docker) to target jobs.- Launch method: "Launch agent via SSH" (most common) or "Launch agent by Java Web Start (JNLP)" for Windows.
4. Provide host, credentials (SSH key or password).
5. Save – the agent will connect.
Using Labels in Pipelines
In a declarative pipeline, specify the agent label to run on that node.
pipeline {
agent { label 'linux' }
stages {
stage('Build') {
steps { sh 'make' }
}
}
}Docker Agents (Ephemeral)
You can use Docker containers as agents – each build gets a fresh container.
pipeline {
agent {
docker {
image 'maven:3.8-openjdk-17'
args '-v /tmp:/tmp'
}
}
stages {
stage('Build') {
steps { sh 'mvn compile' }
}
}
}Agent Management Tips
- Use labels to group agents (e.g.,
windows,ubuntu,high-mem). - Set number of executors per agent (parallel builds).
- Monitor agent health via "Nodes" page.
- For cloud environments, use plugins like "Amazon EC2" or "Azure VM Agents" to auto‑scale.
Two Minute Drill
- Agents offload build execution from master.
- Add agents via "Manage Jenkins" → "Nodes".
- Use labels to target specific agent types.
- Docker agents provide ephemeral, clean environments.
Need more clarification?
Drop us an email at career@quipoinfotech.com
