Skip to content
Latchkey

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.

Jenkins console
Cancelling nested steps due to timeout
Sending interrupt signal to process
Timeout has been exceeded
script returned exit code 143

Diagnose 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.

Jenkinsfile
// 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.

Jenkinsfile
timeout(time: 30, unit: 'MINUTES') {
  sh './run-integration-tests.sh'
}

Find and fix the hang

  1. Check whether a step is waiting on input or stdin. Wrap interactive prompts so unattended runs do not block.
  2. Ensure subprocesses handle SIGTERM; exit code 143 (128+15) means the process was killed, not that it exited cleanly.
  3. 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 input steps 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.

Frequently asked questions

What causes Jenkins pipeline timeout?
There are 2 common causes: the step genuinely needs more time and a hung step waiting on something that never comes. A build, test suite, or deploy grew past the timeout you set.
How do I fix Jenkins pipeline timeout?
There are 2 fixes depending on which cause you have: set an appropriate timeout and scope it tightly and find and fix the hang. Work through them in order, since the first is the most common.
What does Jenkins pipeline timeout actually mean?
The build is aborted mid-stage with Cancelling nested steps due to timeout followed by Timeout has been exceeded.
How do I stop Jenkins pipeline timeout happening again?
Wrap long stages in a scoped timeout {} rather than relying on a huge global one. The prevention section lists 3 changes that keep it from recurring.

Related guides

References

This is a timeout, not a logic error. Latchkey detects, repairs, and retries it for you. Start free → 30-day trial · No credit card