In this episode we discuss how to analyze Jenkins logs from the System Log to agent logs, plus the Replay and Snippet Generator features for testing pipeline changes without a new commit. We also learn to handle JVM issues such as OOM, thread dumps, and disconnected agents.

In episode 18 we kept Jenkins healthy with backups and monitoring. But however good the system is, pipelines will still fail — and what sets great engineers apart is how fast they find the root cause. In this episode we go into detective mode: reading logs correctly, testing changes without a commit, and handling the JVM issues that most often cause trouble.
We will discuss:
/pipeline-syntax to produce Groovy syntax.Every event on the controller is recorded in the System Log, accessed from Manage Jenkins then System Log. There we can filter by level (ALL, SEVERE, WARNING, INFO, FINE) and search for error messages without opening files on the server.
The actual log files live under JENKINS_HOME/logs/. For a recent incident, the most effective filter is to look for SEVERE and WARNING messages:
grep -E "SEVERE|WARNING" /var/lib/jenkins/logs/jenkins.log | tail -50When an agent disconnects or fails to connect, the agent log is on each node's page: Manage Jenkins then Nodes then the agent name, then click Log. From there we can see the cause of the connection failure, such as a mismatched SSH key or a wrong host address.
Tip
Use log filtering by Java package, for example jenkins.model or hudson.slaves, to narrow the search area in the System Log. Do not read the entire log at once.
The Replay feature is a lifesaver when a pipeline fails at a specific line. Instead of editing the Jenkinsfile, committing, and pushing just to test one line, click Replay on the failed build page. Jenkins opens an editor with the exact same pipeline contents, and we can edit directly, then rerun that build.
steps {
echo "Debug: WORKSPACE = ${env.WORKSPACE}"
sh 'ls -la ${WORKSPACE}'
}After the test build succeeds, that fix is then committed to the repository. This speeds up debugging iteration because it removes the slow commit-push cycle.
Warning
Replay uses the pipeline version from the selected build, not the latest from SCM. Make sure the Replayed build number is the failed one, so the small change hits the right target.
Memorizing the syntax of hundreds of Groovy steps is impossible — and unnecessary. Jenkins provides the Snippet Generator at /pipeline-syntax, which produces complete syntax from a filled-in form.
How to use it:
/pipeline-syntax address on the Jenkins instance.withCredentials or emailext.An example output for the sh step with output capture:
script {
def output = sh(
script: 'curl -s https://api.example.com/health',
returnStdout: true
).trim()
echo "Health: ${output}"
}The Snippet Generator also provides a Declarative Directive Generator for blocks like environment, when, or parameters. This makes the Jenkins UI an interactive documentation that always stays in sync with the installed plugins.
OOM happens when the controller's JVM heap is not enough for the build load. The symptoms: builds die suddenly, the UI responds slowly, and a java.lang.OutOfMemoryError message appears in the System Log. The fix is to raise the heap limit via JVM parameters when running the controller container:
FROM jenkins/jenkins:lts-jdk17
ENV JAVA_OPTS="-Djenkins.install.runSetupWizard=false -Xmx4g -Xms2g"Note
Raise the heap gradually, not straight to the maximum. Monitor the jenkins_jvm_memory_used_bytes metric in Grafana (episode 18) to make sure the allocation matches real needs.
If the controller feels stuck or slow to respond with no pattern, take a thread dump to see what all threads are doing. Jenkins provides the /threadDump endpoint, which shows a snapshot of every thread. From there, look for threads with a repeated BLOCKED or WAITING status.
curl -k "https://jenkins.example.com/threadDump" | grep -A 5 "java.lang.Thread.State: BLOCKED"A disconnected agent is usually not a controller memory issue, but a network or agent process one. The troubleshooting steps:
For agents that often disconnect due to unstable networks, use container-based agents that restart automatically on failure, and check whether a proxy or firewall is dropping the remoting connection because of idleness.
In this episode we learned troubleshooting and debugging:
/pipeline-syntax produces Groovy syntax from an interactive form./threadDump, and disconnected agents are checked through logs and the network.Now we have all the skills to build and maintain Jenkins. In episode 20, the final episode of this series, we bring everything together into one complete production-grade enterprise pipeline case study — from webhook to production deployment. See you there!