Jenkins build queue is blocked because the Jenkins controller can’t schedule any new builds onto the available agents.

Common Causes and Fixes

1. Agent Offline or Unreachable

  • Diagnosis: Check the Jenkins UI for agent status. If agents show as offline or unreachable, investigate network connectivity between the controller and agents.
    • Command: On the Jenkins controller, ping <agent_hostname_or_ip> and telnet <agent_hostname_or_ip> 22 (for SSH).
  • Fix: Ensure the agent process is running and accessible.
    • Command (Linux agent): sudo systemctl start jenkins-agent or sudo service jenkins-agent start
    • Command (Windows agent): Open services.msc and start the Jenkins agent service.
    • Why it works: The Jenkins controller needs to establish a persistent connection (usually via JNLP or SSH) to the agent to send build commands. If this connection is down, the agent appears offline.

2. Agent Busy or Overloaded

  • Diagnosis: In Jenkins UI, check the "Build Executor Status" section. If all executors on available agents are shown as busy, and no builds are running, it implies a deadlock or a very long-running build that isn’t releasing its executor.
    • Check: Navigate to /manage/system/ on the Jenkins controller and look at the "System Information" section for "Build Queue". See if builds are stuck in the queue for an unusually long time.
  • Fix:
    • Identify long-running/stuck builds: Go to the "Build Queue" page and look for jobs that have been waiting indefinitely. Click on them to see details. If a build is stuck, manually cancel it from its build history.
    • Increase agent capacity: If your workload consistently exceeds capacity, provision more agents or add more executors to existing agents (if hardware permits).
    • Why it works: Each build job requires an executor on an agent. If all executors are occupied by builds that are either genuinely running for a long time or are stuck due to a bug, no new builds can be scheduled.

3. Agent Labels Misconfiguration

  • Diagnosis: Jobs are configured to run on specific agent labels (e.g., docker or java11). If no agent is currently online and connected that has the required label, the job will wait.
    • Check: In Jenkins UI, go to "Manage Jenkins" -> "Nodes". For each agent, verify its "Labels". Then, for a job stuck in the queue, examine its configuration to see which labels it requires.
  • Fix:
    • Correct job labels: Edit the job configuration and update the required labels to match available agents.
    • Add labels to agents: Edit the agent configuration in Jenkins and assign the necessary labels.
    • Why it works: Jenkins uses labels as a way to categorize and group agents. Jobs are assigned to agents based on these labels. A mismatch means the scheduler can’t find a suitable agent.

4. Jenkins Controller Resource Exhaustion

  • Diagnosis: If the Jenkins controller itself is running out of memory (OOM) or CPU, it can become unresponsive and unable to process the build queue or communicate effectively with agents.
    • Command (Linux controller): top -H -p $(pgrep -f jenkins.war) or free -m to check memory.
    • Check Jenkins logs: Look for OutOfMemoryError or high CPU usage warnings in $JENKINS_HOME/jenkins.log.
  • Fix:
    • Increase JVM heap size: Edit the Jenkins startup script or jenkins.xml (Windows) to increase the -Xmx and -Xms values. For example, to set max heap to 4GB: -Xmx4096m -Xms1024m.
    • Restart Jenkins: A restart can temporarily alleviate resource pressure.
    • Why it works: Jenkins runs as a Java process. Insufficient heap memory leads to excessive garbage collection or OOM errors, preventing it from performing its core functions, including queue management.

5. Agent Launch Failure (JNLP/SSH)

  • Diagnosis: Agents configured to launch automatically (e.g., via JNLP or SSH) might fail to start due to network issues, incorrect credentials, or missing prerequisites on the agent machine.
    • Check Jenkins logs: Look for errors related to agent connection attempts (e.g., "JNLP agent connection failed", "SSH connection failed").
    • Check agent logs: On the agent machine, check the agent’s log file (e.g., /var/log/jenkins/jenkins-agent.log or similar) for startup errors.
  • Fix:
    • Verify agent configuration: Double-check the agent’s connection details in Jenkins (host, port, credentials).
    • Ensure prerequisites: Make sure Java is installed and configured correctly on the agent, and that SSH keys or JNLP secret are valid.
    • Manual start: Try starting the agent manually on the agent machine to see verbose error output.
    • Why it works: If an agent cannot successfully connect and register with the controller, it will never become available to accept builds, regardless of its actual running status.

6. Jenkins Plugin Issues

  • Diagnosis: A faulty or incompatible Jenkins plugin can cause various issues, including queue blocking. This is often indicated by unusual behavior in the Jenkins UI or specific errors in the Jenkins system logs.
    • Check Jenkins logs: Look for exceptions or errors related to plugin loading or specific plugin functionalities around the time the queue became blocked.
  • Fix:
    • Disable suspect plugins: In "Manage Jenkins" -> "Plugins" -> "Advanced", try disabling recently installed or updated plugins one by one.
    • Update plugins: Ensure all plugins are up to date.
    • Restart Jenkins: After making plugin changes, restart the Jenkins controller.
    • Why it works: Plugins extend Jenkins functionality. A bug in a plugin can interfere with core Jenkins processes like queue management or agent communication.

The next error you’ll likely encounter if you fix all of the above is a java.lang.OutOfMemoryError: PermGen space if your Jenkins controller JVM was configured with insufficient permanent generation space.

Want structured learning?

Take the full Jenkins course →