# Any option to enable "restart" for this "dynamic stage" creation pipeline?

**URL:** <https://community.jenkins.io/t/any-option-to-enable-restart-for-this-dynamic-stage-creation-pipeline/12207>\
**Category:** Ask a question\
**Tags:** pipeline\
**Created:** [February 2, 2024, 3:35pm UTC](https://community.jenkins.io/t/any-option-to-enable-restart-for-this-dynamic-stage-creation-pipeline/12207 "2024-02-02T15:35:05Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![alnhk](https://dub1.discourse-cdn.com/flex013/user_avatar/community.jenkins.io/alnhk/32/6906_2.png) [@alnhk](https://community.jenkins.io/u/alnhk)\
**Post date:** [February 2, 2024, 3:35pm UTC](https://community.jenkins.io/t/any-option-to-enable-restart-for-this-dynamic-stage-creation-pipeline/12207/1 "2024-02-02T15:35:05Z")

</div>

I have this piece of the pipeline

```auto
def list
pipeline {
    agent {label 'it'}
    options {buildDiscarder(logRotator(daysToKeepStr: '7', numToKeepStr: '1'))}
    stages {
        stage('Create List') {

            steps {
                script {
                    // you may create your list here, lets say reading from a file after checkout
                    list = ["Test-1", "Test-2", "Test-3", "Test-4", "Test-5"]
                }
            }
            post {
                cleanup {
                    cleanWs()
                }
            }
        }
        stage('Dynamic Stages') {
            
            steps {
                script {
                    for(int i=0; i < list.size(); i++) {
                        stage(list[i]){
                            echo "Element: $i"
                        }
                    }
                }
            }
            post {
                cleanup {
                    cleanWs()
                }
            }
        }
    }
}

```

And this shows, however, if we select stage name “Test-4”, its not allowing us to restart, only “Dynamic Stage” has option for restart. Is there any way to enable “Restart” ?

 ![image](https://europe1.discourse-cdn.com/flex013/uploads/jenkins/original/2X/b/bb27765c1a1ba300163e1dde634f4ba7f96b1794.png)

Same goes with this similar where below shows ability to dynamically create stages however option to. “Restart” dynamically created stages is not enabled. Appreciate if there is any other ideas?

```auto

        stage ('Create Model Stages dynamically...'){
            steps {
                script {
                    def build_properties = readProperties file: "file.txt"
                        build_properties.each{ k,v ->
                            image_properties[k]=v
                             stage ("Validate Model - ${k}") {
                                 println "${v}"
                          }
                    }
                }
            }
        }

```

---

<div class="post-metadata">

**Author:** ![jglick](https://dub1.discourse-cdn.com/flex013/user_avatar/community.jenkins.io/jglick/32/77_2.png) [@jglick](https://community.jenkins.io/u/jglick)\
**Post date:** [February 2, 2024, 4:50pm UTC](https://community.jenkins.io/t/any-option-to-enable-restart-for-this-dynamic-stage-creation-pipeline/12207/2 "2024-02-02T16:50:45Z")

</div>

No, the stage restart feature is part of Declarative Pipeline, and while you may be using the top-level `pipeline {…}` structure the use of the `script` block shows that this is essentially Scripted, for which there is no direct equivalent. (At least not in Jenkins; CloudBees CI offers a `checkpoint` step which works in Scripted Pipeline and would support a dynamic stage list like the one you show.)

If you foresee the need to restart a stage and the reason to do so can be described mechanically, you would be better off just doing so automatically to begin with, normally using the `retry` step, optionally with `conditions`. (For complex cases you can directly use programming constructs like `for` loops and `try`-`catch` blocks, but then you lose some `retry` step magic like passing through explicit build aborts.)

You can also do retries directly in Bourne shell script or whatever is actually being run inside the stage. The same applies to the Pipeline `timeout` step vs. the Linux `/usr/bin/timeout`; it is better to use the platform native system where it would suffice. (Whereas the Pipeline steps could wrap around a larger block of Jenkins automation including allocation of an agent.)

---

<div class="post-metadata">

**Author:** ![alnhk](https://dub1.discourse-cdn.com/flex013/user_avatar/community.jenkins.io/alnhk/32/6906_2.png) [@alnhk](https://community.jenkins.io/u/alnhk)\
**Post date:** [February 2, 2024, 5:10pm UTC](https://community.jenkins.io/t/any-option-to-enable-restart-for-this-dynamic-stage-creation-pipeline/12207/3 "2024-02-02T17:10:16Z")

</div>

Good day @jglick : yes we are using CloudBees CI, can you please share an example we can follow (yes, we do use “Retry” step) yet theres some use-cases that we want to restart manually.

Please share an example to use “CheckPoint” step available to cloudbees CI

---

<div class="post-metadata">

**Author:** ![alnhk](https://dub1.discourse-cdn.com/flex013/user_avatar/community.jenkins.io/alnhk/32/6906_2.png) [@alnhk](https://community.jenkins.io/u/alnhk)\
**Post date:** [February 2, 2024, 5:26pm UTC](https://community.jenkins.io/t/any-option-to-enable-restart-for-this-dynamic-stage-creation-pipeline/12207/4 "2024-02-02T17:26:41Z")

</div>

Never mind @jglick : using checkpoint helps! Thank you so very much, first time heard about “checkpoint”
