The Jenkins agent failed to upload build artifacts to the Jenkins controller because the agent’s disk space was exhausted.
Cause 1: Agent Disk Full
Diagnosis: SSH into the Jenkins agent and run df -h. Look for partitions mounted at / or /var/lib/jenkins that are at or near 100% usage.
Fix:
- Clean up old builds: On the agent, navigate to the Jenkins workspace directory (e.g.,
/var/lib/jenkins/workspace) and delete old, completed build directories.
This command removes directories older than 30 days.find /var/lib/jenkins/workspace -maxdepth 1 -type d -mtime +30 -exec rm -rf {} \; - Clear Jenkins agent logs: Jenkins agent logs can grow large. Locate and remove old log files.
This command removes log files older than 30 days.find /var/lib/jenkins/remoting/logs -type f -mtime +30 -delete - Increase disk size: If cleaning is a temporary fix, provision a larger disk for the agent.
Why it works: Artifacts are stored on the agent’s filesystem before being transferred to the controller. If the agent’s disk is full, there’s no space for these temporary files, causing the upload to fail.
Cause 2: Network Connectivity Issues
Diagnosis: From the Jenkins agent, try to ping the Jenkins controller’s hostname or IP address. Also, try to curl a known endpoint on the controller (e.g., curl -I http://your-jenkins-controller:8080/login).
Fix:
- Check firewall rules: Ensure that the Jenkins controller’s port (default 8080) is open on any intermediate firewalls or security groups between the agent and the controller.
- Verify DNS resolution: On the agent, confirm that the Jenkins controller’s hostname resolves to the correct IP address using
nslookup your-jenkins-controller. - Restart network services: If connectivity is intermittent, try restarting the network service on the agent:
sudo systemctl restart network(or equivalent for your OS).
Why it works: Jenkins relies on a stable network connection for artifact transfer. Intermittent packet loss, blocked ports, or incorrect DNS prevent the agent from communicating with the controller to upload files.
Cause 3: Insufficient Controller Disk Space
Diagnosis: Log into the Jenkins controller and run df -h. Check the partition where Jenkins stores its home directory (/var/lib/jenkins by default).
Fix:
- Archive old artifacts: Configure Jenkins jobs to archive only necessary artifacts or to automatically delete older archived artifacts. In job configuration, under "Post-build Actions," select "Archive the artifacts" and set an "Optional: Maximum number of builds to keep" or "Optional: Maximum number of days to keep artifacts."
- Clean up old build data: Jenkins retains build history. Regularly clean up old builds via "Manage Jenkins" -> "System Information" -> "Heap Dump" (this is a workaround to trigger cleanup) or by manually deleting old build directories within
/var/lib/jenkins/jobs/. - Increase controller disk size: Provision a larger disk for the Jenkins controller.
Why it works: Artifacts are transferred to and stored on the Jenkins controller. If the controller’s disk is full, it cannot accept the incoming artifact files.
Cause 4: Jenkins Agent Configuration Errors
Diagnosis: Review the jenkins-agent.jar or agent.jar command line arguments used to launch the agent. Specifically, check the JENKINS_URL or the connection details provided.
Fix:
- Correct
JENKINS_URL: Ensure theJENKINS_URLenvironment variable or command-line argument points to the correct, accessible Jenkins controller URL. For example:java -jar agent.jar -jnlpUrl http://your-jenkins-controller:8080/jenkins/computer/your-agent-name/jenkins-agent.jnlp -workDir /home/jenkins/agent - Verify agent connection: In Jenkins UI, navigate to "Manage Jenkins" -> "Nodes" and check the status of the agent. If it’s offline or shows errors, investigate the agent’s launch logs for connection-related issues.
Why it works: An incorrectly configured JENKINS_URL means the agent is trying to connect to the wrong place, preventing any communication, including artifact uploads.
Cause 5: Concurrent Artifact Uploads Overloading Controller
Diagnosis: Monitor the Jenkins controller’s CPU and memory usage during build times, especially when multiple jobs are archiving large artifacts. Use top or htop on the controller.
Fix:
- Rate limit artifact archiving: Configure jobs to archive artifacts incrementally or to only archive critical files. Avoid archiving large, non-essential build outputs.
- Distribute load: If possible, configure jobs to run on different agents or at different times to avoid simultaneous, heavy artifact uploads.
- Increase controller resources: If the controller is consistently overloaded, consider upgrading its CPU and RAM.
Why it works: The Jenkins controller has finite resources. A massive influx of artifact data from multiple agents simultaneously can overwhelm the controller’s processing capabilities, leading to upload failures.
Cause 6: Corrupted Artifacts or Workspace
Diagnosis: Examine the Jenkins job console output for specific error messages related to file corruption or I/O errors during the artifact archiving phase on the agent. Check the agent’s disk for filesystem errors.
Fix:
- Clean workspace: Manually delete the job’s workspace on the agent (
/var/lib/jenkins/workspace/your-job-name) and rerun the build. - Check agent disk health: Run
fsckon the agent’s filesystem (requires unmounting or booting from recovery media, so do this cautiously). - Rerun build: Sometimes, transient I/O errors can be resolved by simply rerunning the build.
Why it works: If the artifact files themselves are corrupted on the agent’s disk due to underlying filesystem issues or incomplete writes, the upload process will fail when Jenkins attempts to transfer these bad files.
The next error you’ll likely encounter is a OutOfMemoryError on the Jenkins controller if you’ve fixed disk space issues but the controller is still struggling to process the artifact data due to insufficient RAM.