Pipeline Restart from a Specific Stage in Jenkins: Skip the Parts That Already Worked
A deep, beginner-friendly guide to how Jenkins lets you re-run a failed pipeline starting from the exact stage that failed, why this is genuinely powerful, and where it can quietly go wrong.
Imagine baking a multi-layer cake: you mix the batter, bake three separate layers, and finally assemble and frost the whole thing. If the frosting step goes wrong — maybe it’s applied unevenly — you wouldn’t throw out the three perfectly good baked layers and start over from raw ingredients. You’d simply redo the frosting step, using the layers you already successfully baked. Restarting a Jenkins pipeline from a specific stage works on exactly this principle: when a long pipeline fails partway through, you often don’t need to redo everything from the very beginning — you can pick up again from the specific stage that failed, reusing the work every earlier stage already successfully completed. This tutorial explains how this capability works, what makes it safe or risky to use, and how to design pipelines that support it well, assuming no prior Jenkins experience.
1What Is Restarting from a Specific Stage?
Before exploring the mechanics, it’s worth clearly separating this from simply re-running a pipeline entirely.
A full re-run versus a partial restart
A full re-run starts a brand-new pipeline execution from the very first stage, exactly as if the pipeline were being triggered for the first time — every stage runs again, regardless of whether it previously succeeded. Restarting from a specific stage is different: it resumes an existing, previously failed run, skipping every stage that already completed successfully and beginning execution again only from a chosen, later point.
Think of a long road trip with several planned stops. If your car breaks down between the third and fourth stop, you don’t drive all the way back to the very beginning once it’s fixed — you resume the trip from exactly where you left off, having already legitimately covered the earlier distance.
Where this capability comes from in Jenkins
This capability is available for declarative pipelines that define their work as a named sequence of stages, and Jenkins exposes it directly from a failed build’s own page — an option to restart the pipeline beginning at any one of its previously defined stages, rather than only offering a single, all-or-nothing “run again” choice.
Full Re-run
Starts entirely fresh from the first stage, regardless of what previously succeeded.
Restart from Stage
Resumes from a chosen stage, skipping every stage that already completed successfully.
Declarative Syntax
The pipeline must be defined using named, declarative stages for this option to be available.
The rest of this tutorial explores exactly what makes this capability genuinely useful, and equally important, what makes it something to use thoughtfully rather than reflexively.
2Why This Capability Exists
This feature exists because, for many pipelines, a full re-run after a failure is wasteful in a very concrete, measurable way.
The cost of redoing already-successful work
A long pipeline might spend twenty minutes building an application, another fifteen minutes running an extensive test suite, and only then reach a five-minute deployment stage that happens to fail due to a temporary, unrelated network issue. A full re-run means redoing the entire thirty-five minutes of already-successful build and test work, purely to retry the five minutes that actually failed.
Reflexively clicking a full re-run for every failure, without considering whether the failure was isolated to a specific stage — this habit quietly wastes significant compute time and slows down feedback for everyone waiting on the pipeline.
Faster recovery from transient, isolated failures
Many pipeline failures are transient and specific to one stage — a temporary network blip during deployment, a flaky external service during a particular test, a momentarily unavailable artifact repository — and restarting from that specific stage lets a team recover from exactly this kind of isolated hiccup in a fraction of the time a full re-run would take.
Reducing unnecessary load on shared infrastructure
Beyond simply saving time, avoiding unnecessary full re-runs also reduces load on shared build agents and any external systems the earlier stages interact with — a meaningful consideration in an organization where many pipelines are competing for the same limited pool of infrastructure.
Recovering Quickly from a Flaky Deployment Target
A pipeline’s final deployment stage fails because the target environment was briefly unreachable. Rather than rebuilding and retesting the entire application again, the team restarts specifically from the deployment stage once the environment is confirmed healthy, recovering in minutes rather than repeating a lengthy build and test cycle.
3The Anatomy of a Restartable Pipeline
Not every pipeline is automatically eligible for this capability — a few specific ingredients need to be in place.
Named, declarative stages as the foundation
For Jenkins to offer a restart option at a specific stage, the pipeline must be written using the declarative syntax’s named stage structure, since these named boundaries are exactly what Jenkins presents as the available restart points — a pipeline without this clear stage structure has no natural points to restart from at all.
| Piece | Role | Everyday Comparison |
|---|---|---|
| Named stages | Define the specific points a restart can begin from | The planned stops along a road trip’s route |
| Preserved build record | Jenkins’s record of exactly what succeeded and what failed | A trip log noting exactly where the breakdown occurred |
| Workspace or artifact state | What earlier, skipped stages actually left behind | The luggage and supplies already loaded into the car |
| Restart trigger | The action of choosing a stage and beginning execution there | The decision to resume the trip from that exact point |
What a restart actually skips, and what it doesn’t
When restarting from a chosen stage, Jenkins skips executing every stage before it entirely — it doesn’t quietly re-verify that earlier stage’s success; it simply trusts the original run’s recorded outcome and proceeds directly to the chosen stage’s logic, executing it as a fresh, brand-new attempt.
This is similar to trusting a trip log’s record that you already passed through the second checkpoint successfully, without physically driving back to re-verify it — you take that record at face value and simply continue forward from where the record says you actually are.
Where workspace state comes into the picture
Because a restarted stage begins in whatever workspace state exists from the original run, whether that state genuinely reflects what a from-scratch run at that point would have produced is a critical, and sometimes surprising, factor in whether the restart behaves correctly — a concern explored in depth in the chapter on idempotency later in this tutorial.
Named Stages
The declared points a pipeline can be restarted from.
Build Record
Jenkins’s trusted record of what previously succeeded.
Existing Workspace
Whatever files and state the original, partially completed run left behind.
4How Jenkins Implements Stage Restart Internally
Understanding the internal mechanics clarifies exactly what Jenkins does, and doesn’t, verify during a restart.
The moment a restart is requested
When a user selects a specific stage to restart from, Jenkins creates a new build record — distinct from, but linked to, the original failed run — and begins executing the pipeline’s declared logic starting at that chosen stage, using the original run’s recorded checkpoint data to determine exactly which stages should be treated as already complete.
sequenceDiagram
participant U as User
participant J as Jenkins
participant Orig as Original Failed Run
participant New as New Restarted Run
U->>J: Select "Restart from Stage: Deploy"
J->>Orig: Reference recorded checkpoint data
J->>New: Create new build, marked as a restart
New->>New: Skip Checkout, Build, Test (trusted as already successful)
New->>New: Execute Deploy stage fresh
What the new build inherits from the original
The restarted build typically inherits the same parameters, the same triggering commit, and, depending on how the underlying agent and workspace are managed, potentially the same workspace on disk — meaning files left behind by the original run’s earlier, successful stages may still be physically present when the restarted stage begins executing.
Because the restarted build is a genuinely new build record, it gets its own build number and its own log — but it’s explicitly linked back to the original run it restarted from, preserving a clear, traceable history of exactly what happened.
No re-verification of earlier stages, by design
It’s worth being explicit that Jenkins does not re-run any correctness checks on the skipped, earlier stages during a restart — it simply trusts that they succeeded, exactly as recorded, and proceeds directly to the chosen stage. This design choice is precisely what makes restart fast, but it’s also precisely why restart isn’t automatically safe for every kind of pipeline, a distinction covered in depth in Chapter 7.
5Data Flow and the Restart Lifecycle
Following one failed build through a restart shows exactly what data carries forward, and what’s regenerated.
The original pipeline runs and fails partway through
Earlier stages complete successfully; a later stage fails, halting the original run.
A user reviews the failure and chooses to restart
After investigating and addressing the root cause, they select the specific failed stage to restart from.
A new, linked build begins
Jenkins creates a new build record, explicitly referencing the original run it’s restarting.
Execution resumes directly at the chosen stage
The pipeline runs the chosen stage’s logic fresh, using whatever workspace state is currently present.
The restarted build completes independently
The new build reaches its own final outcome, recorded as its own distinct, but clearly linked, build history entry.
What flows forward from the original run
Beyond simply the recorded knowledge of which stages already succeeded, whatever a skipped stage physically produced — a compiled artifact sitting in the workspace, an environment variable set earlier in the run — potentially carries forward into the restarted execution, since the restart doesn’t reset the workspace to a truly clean, blank state by default.
This is similar to resuming a paused video game from a saved checkpoint — your character’s inventory and progress from before the pause are still there, exactly as they were, rather than the game resetting you back to a completely fresh start.
6Types of Restart Scenarios and Where They’re Used
Different kinds of failures call for genuinely different restart decisions.
Transient Infrastructure Failure
A stage fails due to a temporary network issue, an unavailable external service, or a momentary resource shortage — restarting from exactly that stage once the underlying issue clears is usually the fastest, most appropriate response.
Flaky Test Failure
A test known to occasionally fail for reasons unrelated to actual code correctness causes a stage to fail — restarting from that specific test stage can confirm whether the failure was genuinely flaky, without repeating an unrelated, already-successful build stage.
Approval Gate Timeout or Rejection
A pipeline pauses at a manual approval gate that times out or is initially declined by mistake — restarting from that gate lets the approval be requested again without repeating every stage that ran before it.
Genuine Code Defect
A stage fails because of an actual bug in the code being built or tested — in this case, as covered in Chapter 13, restarting from that stage is generally not appropriate, since the underlying code itself needs to change first.
Recognizing which scenario you’re actually in
Correctly diagnosing which of these categories a given failure falls into — genuinely transient versus a real underlying code problem — is the single most important judgment call in deciding whether a stage restart is the right response, or whether a fresh, full pipeline run is actually necessary instead.
| Failure Type | Restart Appropriate? | Why |
|---|---|---|
| Transient infrastructure issue | Yes | The underlying cause is unrelated to the code itself |
| Known flaky test | Often yes, with caution | Confirms whether the failure was genuinely intermittent |
| Approval gate issue | Yes | No code-related work needs to be redone |
| Genuine code defect | No | The code itself must change before any rerun makes sense |
7Idempotency: The Core Requirement for Safe Restart
This single concept determines, more than any other, whether restarting a given pipeline from a given stage is actually safe.
What idempotency means, in plain terms
A stage is idempotent if running it again produces the same correct result regardless of whether it’s the first attempt or a later retry — and critically, regardless of whether earlier stages ran moments ago in this same execution, or hours ago in an original run being restarted from. An idempotent deployment stage, for example, safely re-deploys the exact same version without causing any harm if run a second time.
Flipping a light switch to “on” is idempotent — doing it once or five times in a row leaves the light in exactly the same final state. Depositing a fixed amount of money into a bank account, however, is not idempotent — doing it twice by mistake leaves twice as much money as intended.
Why a restarted stage’s assumptions can quietly be wrong
A stage restart trusts that everything before it happened exactly as the workspace and build record suggest — but if a stage isn’t genuinely idempotent, or if something in the environment changed between the original failed attempt and the restart, that trust can be misplaced, leading to subtly incorrect or even harmful behavior that a from-scratch run would never have produced.
Restarting a non-idempotent stage — one that sends a one-time notification, increments a counter, or triggers an irreversible external action — without recognizing that running it again could duplicate that exact action a second time.
Designing pipelines with restart safety in mind from the start
Rather than discovering idempotency problems only after an accidental duplicate action, deliberately designing stages to be safely repeatable — checking whether an action has already been performed before performing it again, for example — pays off significantly the first time an unexpected failure makes a stage restart genuinely useful.
An Idempotent Deployment Stage
A deployment stage designed to check the currently deployed version before acting, and to skip re-deploying if the target version is already correctly running, can be safely restarted any number of times with no risk of unintended duplicate effects.
8Advantages and Trade-offs
Stage restart offers genuine efficiency benefits, but those benefits only materialize under the right conditions.
Advantages
- Dramatically speeds up recovery from failures isolated to a single stage
- Reduces unnecessary load on shared build infrastructure
- Preserves a clear, linked history between the original run and the restart
- Encourages pipeline authors to think deliberately about stage boundaries and idempotency
- Provides a faster feedback loop for diagnosing whether a failure was genuinely transient
Disadvantages / Trade-offs
- Trusts earlier stages’ recorded success without re-verification, which can occasionally be wrong
- Risky when used on stages with side effects that aren’t genuinely idempotent
- Only available for pipelines using the declarative, named-stage structure
- Can mask an underlying flakiness problem if used habitually without investigating root cause
The risk of using restart as a substitute for investigation
It’s tempting to reflexively restart a failed stage without genuinely understanding why it failed, especially when restart is fast and convenient — but doing this repeatedly, for a stage that’s actually failing for a real, recurring reason, simply delays a genuine fix while consuming everyone’s patience with an increasingly unreliable pipeline.
Restart is a tool for recovering quickly from genuinely isolated, transient failures — it is not a substitute for actually understanding and fixing a stage that fails for real, recurring reasons.
9Security Considerations
Because restart bypasses re-running earlier stages, it carries specific security implications worth understanding.
Restart and stages that perform security-relevant checks
If an earlier, skipped stage was responsible for a security-relevant check — such as a static analysis scan or a dependency vulnerability check — a restart trusts that check’s original result without repeating it, meaning if something in the environment or the scanning tool’s own database changed since the original run, the restarted build proceeds without benefiting from that update.
This is similar to trusting a security guard’s earlier clearance of a building without re-checking it, even though hours have passed and circumstances could have changed since that original check was made.
Restarting past an approval gate
Special care is warranted around restart behavior involving manual approval gates — an organization’s policy should be explicit about whether restarting from a stage after an approval gate genuinely requires that approval to be granted again, or whether it silently reuses the original approval decision, since these have very different security implications.
Problem
A pipeline is restarted from a stage positioned after a required manual approval gate, without any policy clarifying whether that approval must be re-obtained.
Why It’s Harmful
An approval originally granted under one set of circumstances could be implicitly reused for a restarted run under meaningfully different circumstances, undermining the purpose of requiring the approval in the first place.
Correct Approach
Establish and enforce an explicit policy: either require re-approval for any restart occurring after a critical approval gate, or restrict restart availability so it cannot begin from a point after such a gate at all.
Auditing restarted builds distinctly from fresh runs
Because a restarted build skips genuine re-execution of its earlier stages, maintaining a clear, visible distinction in build history and audit logs between a fresh, full run and a restarted one helps anyone reviewing that history understand exactly what was, and wasn’t, actually re-verified for that specific deployment or release.
10Monitoring, Logging, and Metrics
Tracking how restart is actually being used across an organization reveals both its benefits and any misuse.
Tracking restart frequency by stage
Recording how often each specific stage across the organization’s pipelines is restarted reveals which stages are chronically unreliable and worth genuinely fixing, distinct from those experiencing only rare, truly transient issues that restart handles perfectly well.
Restart Frequency by Stage
How often a specific named stage is the target of a restart, across all pipelines.
Time Saved by Restart
The estimated compute time saved by skipping earlier, already-successful stages.
Restart Success Rate
What proportion of restarted builds ultimately succeed, versus fail again for the same or a different reason.
Repeated Restarts of the Same Build
How often a single original failure requires more than one restart attempt before finally succeeding.
graph TD
A[Restart Triggered] --> B[Stage and Reason Logged]
B --> C[Restart Frequency Dashboard]
C --> D[Chronically Unreliable Stages Flagged]
D --> E[Team Investigates Root Cause]
Distinguishing healthy restart usage from a symptom of a deeper problem
A low, occasional rate of restarts for a specific stage is generally a healthy sign of the feature working exactly as intended, while a high, persistent rate of restarts for that same stage is a strong signal that the stage itself has a real, recurring problem deserving direct investigation rather than repeated restarting.
11Design Patterns and Anti-Patterns
A handful of recurring design choices separate pipelines that support restart gracefully from ones where restart quietly causes harm.
Pattern: designing every stage to be genuinely idempotent
As discussed in Chapter 7, deliberately designing every stage — especially ones with real-world side effects like deployments or notifications — to be safely repeatable is the single most important design choice supporting safe, worry-free restart across an entire pipeline.
Good Pattern: Check-Before-Act Deployment
A deployment stage first checks whether the target environment already reflects the intended version before taking any deployment action, making it completely safe to restart from that stage any number of times.
Anti-pattern: a notification stage with no duplicate protection
A stage that sends a one-time notification — announcing a release, for example — with no mechanism to detect and prevent a duplicate send, will fire that same notification again every time the pipeline is restarted from that point, quickly becoming confusing or annoying for anyone receiving it.
Problem
A stage sends an important one-time notification with no mechanism to detect that this specific notification has already been sent for this release.
Why It’s Harmful
Restarting the pipeline from a point before this stage causes the same notification to be sent again, confusing recipients and undermining trust in the notification’s reliability.
Correct Approach
Track whether a specific notification has already been sent for a given build or release, and skip sending it again if a restart causes that same stage to execute a second time.
Pattern: keeping stages small and focused
Following the same general pipeline-design principle discussed elsewhere in this guide, smaller, more focused stages give restart much finer-grained control — a pipeline with one enormous, all-encompassing stage offers no meaningful restart granularity at all, while several smaller stages let a restart skip precisely the work that already succeeded.
12Best Practices and Common Mistakes
These are the lessons most teams learn only after a restart has caused an unexpected duplicate action or a confusing outcome.
Design Every Stage for Idempotency
Assume any stage might one day be restarted, and design its side effects to be safely repeatable.
Investigate Before Restarting
Understand the actual cause of a failure before deciding whether restart is the appropriate response.
Set a Clear Policy for Approval Gates
Be explicit about whether restarting past an approval gate requires re-approval.
Track Restart Frequency by Stage
Use restart data to identify and fix chronically unreliable stages, rather than treating restart as a permanent workaround.
Common mistake: restarting a stage that depends on a fresh, clean workspace
Some stages genuinely need a completely clean starting state to behave correctly, and restarting into a workspace still holding leftover files or state from the original run’s earlier stages can cause subtle, hard-to-diagnose problems that wouldn’t occur in a genuinely fresh, full pipeline run.
If a stage’s correct behavior genuinely depends on starting from a clean, empty workspace, that stage may not be a good candidate for restart at all — a full re-run might be the more reliable choice in that specific case.
Common mistake: treating restart frequency data as unimportant
Ignoring how often a specific stage is being restarted across the organization misses a valuable, freely available signal about which parts of the shared pipeline infrastructure genuinely need attention, rather than continuing to quietly rely on restart as an ongoing workaround.
13Limitations and When Restart Isn’t Appropriate
Recognizing the boundaries of this feature is just as important as understanding how to use it.
When the underlying code itself is the problem
If a stage failed because of an actual defect in the application code being built or tested, restarting that same stage will simply fail again in exactly the same way, since nothing about the underlying cause has changed — in this situation, the code needs to be fixed and a genuinely fresh pipeline run triggered against the corrected version.
Restarting a failed stage caused by a real code defect is like resuming a road trip from a broken-down car without actually fixing the car — you’ll simply break down again in exactly the same spot.
When the environment has meaningfully changed since the original run
If significant time has passed since the original run, or if the target environment or dependencies have meaningfully changed in the interim, the assumptions a restart relies on — that everything up to the chosen stage is still valid and current — may no longer hold, making a fresh, full run the safer, more trustworthy choice.
Genuine Code Defects
The stage will fail identically again until the underlying code is actually fixed.
Long-Delayed Restarts
Significant time gaps risk the original run’s assumptions no longer being valid.
Non-Idempotent Side Effects
Stages with irreversible or duplicate-prone actions risk unintended harm if restarted.
Establishing organizational guidance on when to restart versus rerun
Providing pipeline authors and operators with clear, simple guidance — a short decision checklist covering failure type, elapsed time, and stage idempotency — helps ensure restart is used specifically where it genuinely helps, rather than being applied reflexively to every failure regardless of its actual underlying cause.
14Real-World and Industry Examples
Seeing how different kinds of organizations apply stage restart makes the concept concrete.
A Team with a Long, Heavy Build Pipeline
A forty-minute build and test sequence, followed by a much shorter deployment stage, sees frequent restarts specifically targeting only the deployment stage when it fails due to occasional target-environment flakiness, saving the team significant time compared to always redoing the full sequence.
A Regulated Organization with Strict Approval Requirements
A firm policy requires that any restart occurring after a mandatory production approval gate must obtain a fresh approval, ensuring no restart can silently bypass the intended human review process.
A Team Investigating Test Flakiness
Restart data reveals that one specific test stage is restarted far more often than any other across the organization’s pipelines, prompting a dedicated investigation that ultimately identifies and fixes a genuinely flaky underlying test.
A Platform Team Establishing Idempotency Standards
Recognizing the risk of non-idempotent stages, a platform team publishes internal guidance requiring every deployment and notification stage in shared pipeline templates to be explicitly designed for safe restart before being approved for organization-wide use.
A common thread across all four examples
In each case, the organization treats stage restart as a genuinely powerful capability that deserves deliberate design and clear policy, rather than an incidental convenience used without much thought — recognizing that its real value depends entirely on the discipline surrounding how and when it’s actually used.
15Frequently Asked Questions
Straightforward answers to the questions almost every newcomer to pipeline stage restart asks.
No — as explained in Chapter 4, Jenkins trusts the original run’s recorded outcome for earlier stages without re-running or re-verifying them, which is exactly what makes restart fast but also why it requires careful judgment.
Not necessarily — as discussed in Chapter 7 and Chapter 13, safety depends heavily on whether that stage, and any stage after it, is genuinely idempotent, and on whether the underlying failure was actually transient rather than a real code defect.
As covered in Chapter 5, they typically remain present when the restarted stage begins, meaning the restarted execution isn’t necessarily starting from a completely clean, blank workspace.
This should be an explicit organizational policy decision, as discussed in Chapter 9 — many organizations require a fresh approval specifically to avoid an old decision being implicitly reused under different circumstances.
As covered in Chapter 10, tracking restart frequency by stage and watching for a persistently high rate for any specific stage is the recommended way to spot a stage that needs genuine investigation, rather than continued restarting.
As discussed in Chapter 13, a significant time gap increases the risk that the original run’s assumptions no longer hold, so a fresh, full re-run is often the safer, more trustworthy choice in that situation.
16Summary and Key Takeaways
Restarting a Jenkins pipeline from a specific stage is a genuinely powerful capability for recovering quickly from failures that are isolated, transient, and unrelated to the actual correctness of everything that ran before them. By trusting an earlier run’s recorded success and resuming execution only from a chosen point, it can turn a lengthy, wasteful full re-run into a fast, targeted recovery — saving time, reducing load on shared infrastructure, and speeding up the feedback loop for diagnosing whether a failure was ever anything more than a passing hiccup. But that same trust is precisely where its risk lives: a stage restart offers no re-verification of what came before it, which means its safety depends entirely on how deliberately a pipeline’s stages were designed. Idempotent stages, clear policy around approval gates, and honest, ongoing attention to which stages are restarted most often are what separate an organization genuinely benefiting from this capability from one quietly accumulating duplicate notifications, stale approvals, and unresolved flakiness behind a comfortable, convenient shortcut.
Key Takeaways
- Restart resumes, rather than redoes — it skips stages already recorded as successful and begins fresh execution only from a chosen point.
- Earlier stages are trusted, not re-verified — this is what makes restart fast, and also exactly why it requires careful judgment about when to use it.
- Idempotency is the core safety requirement — a stage safely restarted any number of times must produce the same correct outcome each time.
- Not every failure is a good candidate — genuine code defects and long-delayed restarts both undermine the assumptions restart depends on.
- Approval gates need an explicit policy — whether a restart past a gate requires fresh approval should never be left ambiguous.
- Restart frequency is a valuable diagnostic signal — a chronically restarted stage points to a real problem worth fixing, not just repeatedly working around.
- Good design makes restart genuinely safe — small, focused, idempotent stages give restart its full value without introducing hidden risk.