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

Last step of a multi-step always block fails if other steps in the stage failed

    XMLWordPrintable

Details

    Description

      Note: This is not the same as https://issues.jenkins-ci.org/browse/JENKINS-46551 because a single step in the post { always { } } block succeeds even if the earlier steps {} block throws an exception.

      The second "echo" statement in the post { always { } } section below fails with the exit code 127, which is the bash exit code from the earlier steps block attempt to run an arbitrary invalid shell command.

      Whereas, including only a single step in the post { always { } } works as expected.

      pipeline {
      agent {
        docker {
          image 'python'
        }
      }
        stages {
          stage('Run Tests') {
            steps {
              sh 'throwcommandnotfound'
            }
            post {
              always {
                echo 'this will succeed'
                echo 'this will fail'
              }
            }
          }
        }
      }
       

       For the second screenshot below, I removed the second "echo" statement.

      Attachments

        Activity

          victor_yousician Victor Balakine added a comment - - edited

          There is a smaller reproduction, without docker dependency

          pipeline {
            agent none
            stages {
              stage('Run Tests') {
                steps {
                  error 'Big Fat Failure'
                }
                post {
                  always {
                    echo 'this will succeed'
                    echo 'this will fail'
                  }
                }
              }
            }
          }

          Unlike JENKINS-46551, flow nodes for EchoSteps don't have ErrorActions. This is purely a Blue Ocean artifact.

          victor_yousician Victor Balakine added a comment - - edited There is a smaller reproduction, without docker dependency pipeline { agent none stages { stage( 'Run Tests' ) { steps { error 'Big Fat Failure' } post { always { echo ' this will succeed' echo ' this will fail' } } } } } Unlike JENKINS-46551 , flow nodes for EchoSteps don't have ErrorActions. This is purely a Blue Ocean artifact.

          People

            Unassigned Unassigned
            jeffgreenca Jeff Green
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated: