Your Jenkins builds are stuck in the queue because the Jenkins controller isn’t able to dispatch them to available agents, usually due to resource contention or misconfiguration on the controller itself.
Common Causes and Fixes for Jenkins Builds Stuck in Queue
-
Controller Overload (CPU/Memory)
- Diagnosis: Check the Jenkins controller’s CPU and memory usage. On Linux, use
toporhtop. Look for Jenkins processes consuming high resources. - Fix:
- Increase Controller Resources: If running Jenkins on a VM or dedicated server, allocate more CPU cores and RAM. For example, if using Docker, adjust the container’s resource limits.
- Optimize Jenkins Jobs: Identify and tune resource-intensive jobs. Look for jobs with long execution times or high memory footprints.
- Reduce Concurrent Jobs: Temporarily reduce the maximum number of concurrent builds allowed in Jenkins global configuration (
Manage Jenkins->Configure System->Max # of concurrent builds). Start with a value like 20 and increase gradually.
- Why it works: The Jenkins controller needs sufficient resources to manage job scheduling, agent communication, and UI responsiveness. Overload prevents it from processing the queue effectively.
- Diagnosis: Check the Jenkins controller’s CPU and memory usage. On Linux, use
-
Insufficient Agent Availability (Offline Agents, No Available Agents)
- Diagnosis:
- Check agent status in
Manage Jenkins->Nodes. Ensure agents are online and connected. - Verify if agents have available executors. An executor is a slot where a build can run. If all executors on all online agents are busy, new builds will queue.
- Check agent status in
- Fix:
- Bring Agents Online: If agents are offline, investigate why. Check agent logs (
jenkins.outoragent.logon the agent machine) for connection errors. Restart the agent process if necessary. - Add More Agents: If you consistently have a high build queue and all agents are busy, you need more build agents. Configure new agents or scale up your cloud-based agent fleet (e.g., EC2, Kubernetes).
- Increase Executors per Agent: If agents have few executors, you can increase them. Go to
Manage Jenkins->Nodes, select an agent, clickConfigure, and adjust theNumber of executors(e.g., from 1 to 5). Be mindful of the agent’s hardware resources; don’t assign more executors than the agent can handle.
- Bring Agents Online: If agents are offline, investigate why. Check agent logs (
- Why it works: Builds require an agent with an available executor to run. If no agents are online or all their executors are occupied, builds will wait in the queue.
- Diagnosis:
-
Agent Labels Mismatch
- Diagnosis:
- Check the
Label expressionconfigured for your jobs (Configure->General->Restrict where this project can be run). - Verify the labels assigned to your agents (
Manage Jenkins->Nodes, select agent,Configure->Labels).
- Check the
- Fix: Ensure that the label expression in your job exactly matches one or more of the labels assigned to your online agents. For example, if a job requires the label
docker, at least one online agent must havedockerlisted in its labels. Correct the job’s label expression or the agent’s labels accordingly. - Why it works: Jenkins uses labels to route jobs to specific types of agents. A mismatch means Jenkins cannot find a suitable agent for the job, even if agents are available.
- Diagnosis:
-
Queue Processing Strategy Issues
- Diagnosis: Jenkins has different strategies for deciding which build to pull from the queue next. The default is "FIFO" (First-In, First-Out). If a long-running build is at the head of the queue, it can block subsequent, shorter builds.
- Fix:
- Prioritize Jobs: Use the "Priority Sorter Plugin" to assign priorities to jobs. This allows higher-priority jobs to jump ahead in the queue. Configure priorities in job settings or globally.
- Consider
Quiet period: While not directly a queue blocker, a long quiet period on a job can delay its execution after a commit. AdjustQuiet periodin job configuration (Configure->Build Triggers) to a lower value (e.g., 1 minute or 0).
- Why it works: By prioritizing, you ensure critical or short jobs aren’t indefinitely delayed by older, potentially long-running ones.
-
Agent Connection Issues / Agent Throttling
- Diagnosis: Agents might appear online but are intermittently disconnecting, or Jenkins might be throttling new connections due to network saturation or controller limitations. Check agent logs for frequent
connection refusedorconnection reseterrors. - Fix:
- Network Stability: Ensure stable network connectivity between the Jenkins controller and agents. Check firewalls, load balancers, and network devices.
- Agent Timeout Settings: In
Manage Jenkins->Configure System->Global properties->Environment variables, you might find settings related to agent connection timeouts. Ensure these are reasonable. For JNLP agents, check theJNLP agent connection timeoutsetting. - Controller Load Balancer/Proxy: If Jenkins is behind a load balancer or proxy, ensure it’s configured correctly for long-lived WebSocket connections required by modern agents.
- Why it works: Intermittent agent disconnections mean an agent might be marked as available but isn’t actually ready to accept a build. Throttling prevents new connections from establishing.
- Diagnosis: Agents might appear online but are intermittently disconnecting, or Jenkins might be throttling new connections due to network saturation or controller limitations. Check agent logs for frequent
-
Scrum, Build Flow, or Pipeline Plugin Conflicts/Bugs
- Diagnosis: Certain plugins that manage complex build workflows (like Pipeline, Build Flow, or even older Scrum plugins) can sometimes introduce bugs that affect queue processing or agent allocation. Check Jenkins system logs (
Manage Jenkins->System Log) for plugin-related errors. - Fix:
- Update Plugins: Ensure all plugins, especially those related to build orchestration and agent management, are updated to their latest stable versions.
- Check Plugin Compatibility: Review the Jenkins changelog and plugin documentation for known issues or incompatibilities.
- Disable Suspect Plugins: If you suspect a specific plugin, try disabling it temporarily to see if the queue starts moving.
- Why it works: Plugin bugs can interfere with Jenkins’ core scheduling logic, leading to builds getting stuck or never dispatched.
- Diagnosis: Certain plugins that manage complex build workflows (like Pipeline, Build Flow, or even older Scrum plugins) can sometimes introduce bugs that affect queue processing or agent allocation. Check Jenkins system logs (
The next error you’ll likely encounter after resolving this is related to a build failing because the environment on the agent isn’t set up correctly, or the build itself has errors.