A pipeline step raised hudson.AbortException, the controlled way Jenkins signals that a step failed and the build should stop.
What this error means
The build ends with hudson.AbortException and a message naming the failing step. Unlike a stack-trace crash, this is a clean, expected failure path with a human-readable reason.
jenkins
hudson.AbortException: script returned exit code 2
at org.jenkinsci.plugins.workflow.steps.durable_task.DurableTaskStep
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
A wrapped step failed
sh, bat, checkout, or build threw AbortException because the underlying command or operation failed.
An explicit error step
Code called error("...") to deliberately fail the build with a message.
How to fix it
Read the message and fix the underlying step
Use the AbortException message to find which step failed and why.
Fix the command, credentials, or input it depends on.
Handle expected failures gracefully
Wrap optional work in catchError or try/catch to continue or set build status intentionally.
Jenkinsfile
catchError(buildResult: 'UNSTABLE', stageResult: 'FAILURE') {
sh 'make optional-task'
}
How to prevent it
Use error() with clear messages for intentional failures so AbortException output explains exactly what went wrong.
Frequently asked questions
What causes Jenkins "hudson.AbortException" build step failed?
There are 2 common causes: a wrapped step failed and an explicit error step. sh, bat, checkout, or build threw AbortException because the underlying command or operation failed.
How do I fix Jenkins "hudson.AbortException" build step failed?
There are 2 fixes depending on which cause you have: read the message and fix the underlying step and handle expected failures gracefully. Work through them in order, since the first is the most common.
What does Jenkins "hudson.AbortException" build step failed actually mean?
The build ends with hudson.AbortException and a message naming the failing step.
How do I stop Jenkins "hudson.AbortException" build step failed happening again?
Use error() with clear messages for intentional failures so AbortException output explains exactly what went wrong.