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

A failure in post/always should not prevent the post/failure block to be called

    XMLWordPrintable

Details

    Description

      Hey o/ ,

      If there's an error in some step of the post/always {} block, it seems like this will stop the processing of the post sub-steps.
      I put it Critical, but it almost seems like a blocker: this seems a common use case and counter-intuitive, so I hope you'll agree this is not expected/intended.

      Typical case:

      • I want to always generate some reports (junit, say)
      • I want to notify people *only* on failure

      If something goes wrong in always, still the failure notification should go out for instance.

      Reproduction code:

      pipeline {
          
          agent {
              label 'linux'
          }
          
          post {
              always {
                  echo "ALWAYS THE SUN!!!"
                  junit '**/nonexisting_to_make_this_fail/*.xml'
              }
              failure {
                  echo "WE FAILED MISERABLY! I won't be shown because junit step failed above"
              }
          }
          
          stages {
              stage('bim') {
                  steps {
                      sh "echo bonjour"
                      
                      sh "exit 1"
                  }
              }
          }
      }
      

      Attachments

        Issue Links

          Activity

            batmat Baptiste Mathus created issue -
            abayer Andrew Bayer made changes -
            Field Original Value New Value
            Status Open [ 1 ] In Progress [ 3 ]
            abayer Andrew Bayer made changes -
            Status In Progress [ 3 ] In Review [ 10005 ]
            abayer Andrew Bayer made changes -
            Remote Link This issue links to "PR #90 (Web Link)" [ 15246 ]
            abayer Andrew Bayer made changes -
            Resolution Fixed [ 1 ]
            Status In Review [ 10005 ] Resolved [ 5 ]
            cloudbees CloudBees Inc. made changes -
            Remote Link This issue links to "CloudBees Internal OSS-1833 (Web Link)" [ 18545 ]
            bitwiseman Liam Newman made changes -
            Status Resolved [ 5 ] Closed [ 6 ]

            People

              abayer Andrew Bayer
              batmat Baptiste Mathus
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: