Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-48661

Execute stage only after initial pipeline execution

XMLWordPrintable

    • 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.

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

              Created:
              Updated:
              Resolved: