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

Supporting "post" steps at Pipeline and Stage level

XMLWordPrintable

    • iapetus, 1.0, Blue Ocean 1.0-rc3, Blue Ocean 1.0-rc4, Blue Ocean - 1.1-beta-1, Blue Ocean - 1.1-beta2, Blue Ocean 1.1-beta4

      Post steps

      • Runs after a stage has finished executing
      • Runs after a pipeline has finished executing

      Can run when:

      • Always - even if the steps before the post steps fail, the post steps will always run
      • Failed - runs only when the proceeding steps have failed
      • Success - runs only when the proceeding steps have passed
      • unstable - runs only when the proceeding steps have been marked as unstable
      • changed - runs only when the state has changed relative to the previous run
        • e.g. stage "foo" was success in run 1, then fails in run 2 would these steps ever be run

      https://jenkins.io/doc/pipeline/tour/post/

      Example

      pipeline {
          agent any
          stages {
              stage('No-op') {
                  steps {
                      sh 'ls'
                  }
              }
          }
          post {
              always {
                  echo 'One way or another, I have finished'
                  deleteDir() /* clean up our workspace */
              }
              success {
                  echo 'I succeeeded!'
              }
              unstable {
                  echo 'I am unstable :/'
              }
              failure {
                  echo 'I failed :('
              }
              changed {
                  echo 'Things were different before...'
              }
          }
      }
      

            jamesdumay James Dumay
            jamesdumay James Dumay
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: