• Declarative backlog

      This is the use case I was discussing in JENKINS-45455
      In the context of restarting pipelines from a certain stage it might be useful to have controls for a stage to only execute in one of these restarted runs. For me, there are times when I'd like manually controlled artifact delivery (where the artifacts may be too large to deliver on every build). An input step is inappropriate here because it delays the feedback of the build + test (and can't be revisited later currently).

      Using the idea of restarting pipelines, a Jenkinsfile like this could do the trick:

      pipeline {
          agent any
          stages {
              stage('Build') {
                  //steps...
              }
              stage('Test') {
                  //steps...
              }
              stage('Manual delivery') {
                  when {
                      isRestarted // or isRestartedFromStage if there may also be restarts due to failures?
                  }
                  //steps...
              }
          }
      }
      

      I haven't looked at examples for the feature yet so I don't know what kind of workspace management should be in there too, but that's fine.
      In this pipeline, a build will run the 'Build' and 'Test' stages then skip the delivery stage and complete. At some arbitrary point in the future, I essentially want to continue the pipeline and execute the last stage. I'd be able to restart from this stage and the when condition would be met. A when condition that specifies a stage might be good for safety, if it doesn't bloat/derail the feature too much.

      This also assumes that the feature applies to restarting successfully executed stages.

          [JENKINS-48661] Execute stage only after initial pipeline execution

          Hi stevenfoster

          there is a new feature that could be used for this triggeredBy, please see the following example where a build triggered by an user (vlinde in the example) executes the Stage Two

          pipeline {
              agent any
              stages {
                  stage("One") {
                      steps {
                          echo "Hello"
                      }
                  }
                  stage("Two") {
                      when {
                          triggeredBy cause: "UserIdCause", detail: "vlinde"
                      }
                      steps {
                          script {
                              echo "World"
                              echo "Heal it"
                          }
          
                      }
                  }
              }
          }
          

          Jose Blas Camacho Taboada added a comment - Hi stevenfoster there is a new feature that could be used for this triggeredBy , please see the following example where a build triggered by an user (vlinde in the example) executes the Stage Two pipeline { agent any stages { stage("One") { steps { echo "Hello" } } stage("Two") { when { triggeredBy cause: "UserIdCause", detail: "vlinde" } steps { script { echo "World" echo "Heal it" } } } } }

          Andrew Bayer added a comment -

          Actually, now that I think about it, the added-in-1.3.2 isRestartedRun() when condition does this exactly. I probably should have marked this as a dupe earlier. =)

          Andrew Bayer added a comment - Actually, now that I think about it, the added-in-1.3.2 isRestartedRun() when condition does this exactly. I probably should have marked this as a dupe earlier. =)

            abayer Andrew Bayer
            stevenfoster Steven Foster
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: