Jenkins Pipeline Timeout - "Cancelling nested steps due to timeout"
A timeout {} block (or the global build timeout) elapsed before the steps inside it finished, so Jenkins aborted them. Either the work genuinely takes longer than allotted, or a step is hanging waiting on input, a lock, or a stuck process.
What this error means
The build is aborted mid-stage with Cancelling nested steps due to timeout followed by Timeout has been exceeded. The job ends as ABORTED, not FAILED, and the elapsed time matches the configured timeout.
Cancelling nested steps due to timeout
Sending interrupt signal to process
Timeout has been exceeded
script returned exit code 143Diagnose it: agent, workspace, or sandbox?
Declarative pipeline failures usually come from the environment rather than the script: no matching agent, a dirty reused workspace, or the Groovy sandbox rejecting a method.
// print what the agent actually is
sh 'hostname && whoami && pwd && java -version'
sh 'env | sort | head -40'
// workspaces are REUSED between builds by default
cleanWs()Common causes
The step genuinely needs more time
A build, test suite, or deploy grew past the timeout you set. The limit is simply too tight for the current workload.
A hung step waiting on something that never comes
A process blocked on stdin, an input step with no responder, a lock that is never released, or a child process that ignored SIGTERM can hang until the timeout fires.
How to fix it
Set an appropriate timeout and scope it tightly
Wrap only the steps that need bounding, and pick a limit with headroom over the real duration.
timeout(time: 30, unit: 'MINUTES') {
sh './run-integration-tests.sh'
}Find and fix the hang
- Check whether a step is waiting on
inputor stdin. Wrap interactive prompts so unattended runs do not block. - Ensure subprocesses handle SIGTERM; exit code 143 (128+15) means the process was killed, not that it exited cleanly.
- Add per-step logging so you can see which step stalls before the timeout.
How to prevent it
- Wrap long stages in a scoped
timeout {}rather than relying on a huge global one. - Keep
inputsteps out of the timed critical path, or give them their own timeout. - Track stage durations over time so you raise limits before they start aborting.