Troubleshooting
Jenkins pipelines can fail for many reasons – syntax errors, missing tools, network issues, or resource limits. This chapter covers common problems and how to debug them.
Check Console Output
The first step is always to look at the console output of the failed build. Click on the build number, then "Console Output". Search for the first error.
Common Errors and Fixes
- Syntax error in Jenkinsfile: Use "Pipeline Syntax" checker or run
pipeline { options { ... } }with@NonCPSfor Groovy issues. The console output will point to the line. - Agent offline: Check "Manage Jenkins" → "Nodes". Ensure agent is connected. If using SSH, verify credentials and network.
- Tool not found: Install missing tool (Maven, JDK) via "Global Tool Configuration" or install plugin.
- Permission denied: Use
sudoin steps? Instead, run the agent with necessary permissions or usesudowith password (not recommended). - Out of disk space: Clean up old builds (Jenkins configuration → Discard old builds). Also clean workspace:
deleteDir()in post‑build. - Pipeline hangs: Set a timeout:
options { timeout(time: 1, unit: 'HOURS') }.
Debugging with
echo and shAdd echo statements to print variables and command outputs.
stage('Debug') {
steps {
echo "Workspace: ${WORKSPACE}"
sh 'pwd'
sh 'ls -la'
}
}Replay a Pipeline
Jenkins allows you to edit and replay a previous pipeline execution without committing changes. Go to a completed build, click "Replay". You can modify the Jenkinsfile and run again – useful for debugging.
Jenkins Log Files
For master issues, check
jenkins.log (usually /var/log/jenkins/jenkins.log on Linux). You can also set up logging to a file via java -jar jenkins.war --logfile=/path/log.Common Plugins for Troubleshooting
- Pipeline Utility Steps: Provides
readJSON,writeJSON, etc. - Workspace Cleanup: Automatically delete workspace after build.
- Build Timestamp: Adds timestamps to console output.
Two Minute Drill
- Always read console output for error details.
- Use
echoandshcommands to inspect state. - The "Replay" feature lets you test changes quickly.
- Set timeouts to prevent hung builds.
- Clean workspace and old builds to avoid disk issues.
Need more clarification?
Drop us an email at career@quipoinfotech.com
