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

Post stages should have well defined order

    XMLWordPrintable

    Details

    • Epic Link:
    • Similar Issues:

      Description

      Post stages currently have a defined order in which they run. This limits certain use cases (especially in regards to clean up procedures). It would be nice to be able to specify certain post stages have to run before others.

      Jenkinsfile
      pipeline {
        agent { label 'label' }
        stages {
          stage('stage') {     
            steps {
              echo "stage"
            }
            post {
              success {
                echo "Success"
              }
              always {
                  echo "Always"
                  //deleteDir()
              }
            }
          }
        }
      }
      
      [Pipeline] {
      [Pipeline] stage
      [Pipeline] { (stage)
      [Pipeline] echo
      stage
      [Pipeline] echo
      Post stage
      [Pipeline] echo
      Always
      [Pipeline] echo
      Success
      [Pipeline] }
      [Pipeline] // stage
      [Pipeline] }
      [Pipeline] // node
      [Pipeline] End of Pipeline
      

      In the example Jenkinsfile, I want success to run before always. In my production use case, I want to stash some artifacts for a future stage. The future stage is set up to run on certain conditions, so clean up cannot be delayed.

      How order should be determined is open ended. To me, running in the Jenkinsfile order is more intuitive for a user, but there may be cases where you want to change that.

        Attachments

          Issue Links

            Activity

            Hide
            stefanthurnherr Stefan Thurnherr added a comment -

            Fernando Nasser Have you read the earlier comments in this jira issue? You'll find the jira issue for the 'cleanup' addition in Andrew's comment

            Show
            stefanthurnherr Stefan Thurnherr added a comment - Fernando Nasser Have you read the earlier comments in this jira issue? You'll find the jira issue for the 'cleanup' addition in Andrew's comment
            Hide
            fnasser Fernando Nasser added a comment -

            Thanks Stefan, not sure how I missed the JENKINS-41239 one.

             

            Show
            fnasser Fernando Nasser added a comment - Thanks Stefan, not sure how I missed the  JENKINS-41239 one.  
            Hide
            abayer Andrew Bayer added a comment -

            I think this is clear enough now. =)

            Show
            abayer Andrew Bayer added a comment - I think this is clear enough now. =)
            Hide
            fnasser Fernando Nasser added a comment -

             is.  Many thanks for taking care of this Andrew.

            P.S.: Accordingly to JENKINS-41239  it has been released in Declarative 1.2.9.  But this Jira says fixed-but-unreleased...

             

            Show
            fnasser Fernando Nasser added a comment -  is.  Many thanks for taking care of this Andrew. P.S.: Accordingly to JENKINS-41239  it has been released in Declarative 1.2.9.  But this Jira says fixed-but-unreleased...  
            Hide
            abayer Andrew Bayer added a comment -

            Blech, our statuses are annoying. Fixing up.

            Show
            abayer Andrew Bayer added a comment - Blech, our statuses are annoying. Fixing up.

              People

              • Assignee:
                abayer Andrew Bayer
                Reporter:
                rpocase Robby Pocase
              • Votes:
                10 Vote for this issue
                Watchers:
                18 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: