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

Post when stage is skipped due to when conditional

    XMLWordPrintable

Details

    Description

      The following pipeline does not trigger the post section:

      pipeline {
          agent any
      
          stages {
              stage('Test') {
                  when {
                      expression { return false; }
                  }
                  steps {
                      echo 'working'
                  }
                  post {
                      always {
                          echo 'post'
                      }
                  }
              }
          }
      }
      

      I expected this to actually echo 'post' and for post to also have a 'skipped' option. Would love to see those.

      Attachments

        Issue Links

          Activity

            abayer Andrew Bayer added a comment -

            post on a stage is part of the stage. So if the stage is skipped due to when, that includes the post.

            abayer Andrew Bayer added a comment - post on a stage is part of the stage . So if the stage is skipped due to when , that includes the post .

            abayer thanks for the quick reply. I did not mean this was a defect, just different than what I expected.

            It could be a good idea to add something in the docs about this.

            omervk Omer van Kloeten added a comment - abayer thanks for the quick reply. I did not mean this was a defect, just different than what I expected. It could be a good idea to add something in the docs about this.
            brianjmurrell Brian J Murrell added a comment - - edited

            I would also add, that being able to something when a stage is skipped would be useful.  An example might be to update a CI reporting system (such as Github's commit status checks) that a stage is not being waited for (indefinitely) but rather has been skipped.

            Could we have this This is reopened as an RFE for some such kind of functionality rather than having to re-invent when processing inside the stage since it's not possible to reflect the skipped status of a stage at that point?

            brianjmurrell Brian J Murrell added a comment - - edited I would also add, that being able to something when a stage is skipped would be useful.  An example might be to update a CI reporting system (such as Github's commit status checks) that a stage is not being waited for (indefinitely) but rather has been skipped. Could we have this This is reopened as an RFE for some such kind of functionality rather than having to re-invent when processing inside the stage since it's not possible to reflect the skipped status of a stage at that point?

            Reopening as RFE.

            brianjmurrell Brian J Murrell added a comment - Reopening as RFE.

            Re-closing as I did not see the related issue JENKINS-49944 on this one.

            brianjmurrell Brian J Murrell added a comment - Re-closing as I did not see the related issue JENKINS-49944 on this one.

            People

              Unassigned Unassigned
              omervk Omer van Kloeten
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: