A controller restart typically disrupts Freestyle jobs, but Jenkins Pipelines are checkpointed and can resume after a reboot. In this guide, you’ll modify a simple “Hello World” Pipeline to include a long-running loop, then simulate a controller failure mid-build and observe Jenkins resume from the last checkpoint.Documentation Index
Fetch the complete documentation index at: https://notes.kodekloud.com/llms.txt
Use this file to discover all available pages before exploring further.
Prerequisites
| Component | Requirement |
|---|---|
| Jenkins | 2.x with the Pipeline Plugin installed |
| Maven | “M3” configured under Manage Jenkins > Global Tool Configuration |
| GitHub Repository | Contains your Jenkinsfile and sample code |
| SSH Access | To start/stop the Jenkins controller service |
Ensure your Jenkins controller has sufficient permissions to stop and start the service via
systemctl.1. Add a Long-Running Loop to the Pipeline
Open your Pipeline’sJenkinsfile and locate the Unit Test stage. Here’s the original Declarative Pipeline:
1.1 Why a Direct Loop Fails
If you insert a Groovyfor loop directly under steps, Declarative syntax rejects it:
1.2 Wrapping the Loop in a script Block
Correct the syntax by enclosing the loop inside a script {} step:
main, then trigger the build in Jenkins.

2. Trigger the Build and Observe the Loop
In Pipeline Steps, you’ll see logs like:3. Stop the Jenkins Controller Mid-Loop
SSH into your Jenkins controller and halt the service:
4. Restart Jenkins and Refresh the Console
Bring Jenkins back online:
5. Disabling Resume After Controller Restart
By default, Pipelines pick up after a restart. To enforce an abort-on-restart policy:- In Jenkins, select Configure on your Pipeline project.
- Under Build Triggers, check Do not allow the pipeline to resume if the controller restarts.

Disabling resume will abort any in-progress Pipeline if the controller restarts. Use this only when you need a strict abort-on-restart policy.