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

JUnit failures do not trigger unstable post steps

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: Blocker Blocker
    • junit-plugin
    • None
    • Jenkins 2.46.3
      Junit plugin 1.22.2
      Pipeline API 2.23.1
      Pipeline declarative 1.2.4

      Since the Junit plugin upgrade to 1.22, the junit step do not not trigger unstable post steps anymore.

      Example of declarative pipeline to reproduce :

       

      pipeline {
        stages {
          stage('Build') {
            steps {
      
              ... Maven build with JUnit failures here
      
              junit testResults: '**/target/surefire-reports/TEST-*.xml'
            }
            post {
              always {
                echo "Pipeline status: ${currentBuild.result}"
              }
            }
          }
        }
        post {
          always {
            echo "Pipeline status: ${currentBuild.result}"
          }
          failure {
            echo 'Pipeline status : failure'
          }
          unstable {
            echo 'Pipeline status : unstable'
          }
          changed {
            echo 'Pipeline status : changed'
          }
        }
      }
      
      

       

      With this sample, the console output is :

      Pipeline status: null
      Pipeline status: null
      Pipeline status : changed

      The final state of the build is unstable :
      The unstable post steps (on stage or pipeline level) are never called :

          [JENKINS-48267] JUnit failures do not trigger unstable post steps

          Mathieu LL created issue -
          Mathieu LL made changes -
          Description Original: Since the Junit plugin upgrade to 1.22, the _junit_ step do not set the build status to "failure" anymore.

          Example of declarative pipeline to reproduce :

           
          {code:java}
          pipeline {
            stages {
              stage('Build') {
                steps {

                  ... Maven build with JUnit failures here

                  junit testResults: '**/target/surefire-reports/TEST-*.xml'
                }
                post {
                  always {
                    echo "Pipeline status: ${currentBuild.result}"
                  }
                }
              }
            }
            post {
              always {
                echo "Pipeline status: ${currentBuild.result}"
              }
              failure {
                echo 'Pipeline status : failure'
              }
              unstable {
                echo 'Pipeline status : unstable'
              }
              changed {
                echo 'Pipeline status : changed'
              }
            }
          }

          {code}
           

          With this sample, I have is the console logs :
          {code:java}
          Pipeline status: null
          Pipeline status: null
          Pipeline status : changed{code}

          The final state of the build is unstable : OK.
          The unstable post step is never called : KO
          New: Since the Junit plugin upgrade to 1.22, the _junit_ step do not set the build status to "unstable" anymore.

          Example of declarative pipeline to reproduce :

           
          {code:java}
          pipeline {
            stages {
              stage('Build') {
                steps {

                  ... Maven build with JUnit failures here

                  junit testResults: '**/target/surefire-reports/TEST-*.xml'
                }
                post {
                  always {
                    echo "Pipeline status: ${currentBuild.result}"
                  }
                }
              }
            }
            post {
              always {
                echo "Pipeline status: ${currentBuild.result}"
              }
              failure {
                echo 'Pipeline status : failure'
              }
              unstable {
                echo 'Pipeline status : unstable'
              }
              changed {
                echo 'Pipeline status : changed'
              }
            }
          }

          {code}
           

          With this sample, I have is the console logs :
          {code:java}
          Pipeline status: null
          Pipeline status: null
          Pipeline status : changed{code}

          The final state of the build is unstable : OK.
          The unstable post step is never called : KO
          Mathieu LL made changes -
          Description Original: Since the Junit plugin upgrade to 1.22, the _junit_ step do not set the build status to "unstable" anymore.

          Example of declarative pipeline to reproduce :

           
          {code:java}
          pipeline {
            stages {
              stage('Build') {
                steps {

                  ... Maven build with JUnit failures here

                  junit testResults: '**/target/surefire-reports/TEST-*.xml'
                }
                post {
                  always {
                    echo "Pipeline status: ${currentBuild.result}"
                  }
                }
              }
            }
            post {
              always {
                echo "Pipeline status: ${currentBuild.result}"
              }
              failure {
                echo 'Pipeline status : failure'
              }
              unstable {
                echo 'Pipeline status : unstable'
              }
              changed {
                echo 'Pipeline status : changed'
              }
            }
          }

          {code}
           

          With this sample, I have is the console logs :
          {code:java}
          Pipeline status: null
          Pipeline status: null
          Pipeline status : changed{code}

          The final state of the build is unstable : OK.
          The unstable post step is never called : KO
          New: Since the Junit plugin upgrade to 1.22, the _junit_ step do not set the build status to "unstable" anymore.

          Example of declarative pipeline to reproduce :

           
          {code:java}
          pipeline {
            stages {
              stage('Build') {
                steps {

                  ... Maven build with JUnit failures here

                  junit testResults: '**/target/surefire-reports/TEST-*.xml'
                }
                post {
                  always {
                    echo "Pipeline status: ${currentBuild.result}"
                  }
                }
              }
            }
            post {
              always {
                echo "Pipeline status: ${currentBuild.result}"
              }
              failure {
                echo 'Pipeline status : failure'
              }
              unstable {
                echo 'Pipeline status : unstable'
              }
              changed {
                echo 'Pipeline status : changed'
              }
            }
          }

          {code}
           

          With this sample, the console output is :
          {code:java}
          Pipeline status: null
          Pipeline status: null
          Pipeline status : changed{code}

          The final state of the build is unstable : (/)
          The unstable post step is never called : (x)
          Mathieu LL made changes -
          Summary Original: JUnit failures do not set the build as unstable New: JUnit failures do not set the build as unstable in post steps
          Mathieu LL made changes -
          Summary Original: JUnit failures do not set the build as unstable in post steps New: JUnit failures do not trigger unstable post steps
          Mathieu LL made changes -
          Description Original: Since the Junit plugin upgrade to 1.22, the _junit_ step do not set the build status to "unstable" anymore.

          Example of declarative pipeline to reproduce :

           
          {code:java}
          pipeline {
            stages {
              stage('Build') {
                steps {

                  ... Maven build with JUnit failures here

                  junit testResults: '**/target/surefire-reports/TEST-*.xml'
                }
                post {
                  always {
                    echo "Pipeline status: ${currentBuild.result}"
                  }
                }
              }
            }
            post {
              always {
                echo "Pipeline status: ${currentBuild.result}"
              }
              failure {
                echo 'Pipeline status : failure'
              }
              unstable {
                echo 'Pipeline status : unstable'
              }
              changed {
                echo 'Pipeline status : changed'
              }
            }
          }

          {code}
           

          With this sample, the console output is :
          {code:java}
          Pipeline status: null
          Pipeline status: null
          Pipeline status : changed{code}

          The final state of the build is unstable : (/)
          The unstable post step is never called : (x)
          New: Since the Junit plugin upgrade to 1.22, the _junit_ step do not not trigger unstable post steps anymore.

          Example of declarative pipeline to reproduce :

           
          {code:java}
          pipeline {
            stages {
              stage('Build') {
                steps {

                  ... Maven build with JUnit failures here

                  junit testResults: '**/target/surefire-reports/TEST-*.xml'
                }
                post {
                  always {
                    echo "Pipeline status: ${currentBuild.result}"
                  }
                }
              }
            }
            post {
              always {
                echo "Pipeline status: ${currentBuild.result}"
              }
              failure {
                echo 'Pipeline status : failure'
              }
              unstable {
                echo 'Pipeline status : unstable'
              }
              changed {
                echo 'Pipeline status : changed'
              }
            }
          }

          {code}
           

          With this sample, the console output is :
          {code:java}
          Pipeline status: null
          Pipeline status: null
          Pipeline status : changed{code}

          The final state of the build is unstable : (/)
          The unstable post steps (on stage or pipeline level) are never called : (x)
          Andrew Bayer made changes -
          Link New: This issue duplicates JENKINS-48178 [ JENKINS-48178 ]
          Andrew Bayer made changes -
          Resolution New: Duplicate [ 3 ]
          Status Original: Open [ 1 ] New: Resolved [ 5 ]

            Unassigned Unassigned
            mathieulaude Mathieu LL
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: