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

Build is not marked as UNSTABLE even though failures are found

    Details

    • Similar Issues:

      Description

      I'm using JUnitResultsArchive to record test results, and I'm seeing a weird bug where there are failures reported but the build is not marked unstable.

      This is via Jenkins pipeline, and immediately after the step, I'm echoing the build result:

      step([$class: 'JUnitResultArchiver', testResults: 'build/xunit.xml'])
      echo ">>> BUILD RESULT ${currentBuild.result}"
      

      I can confirm that a test failed in that step, and the result printed is ">>> BUILD RESULT null"

      This doesn't always happen - in some other runs, the result is UNSTABLE as expected.

        Attachments

          Issue Links

            Activity

            Hide
            therealwaldo Will Freeman added a comment -
            Show
            therealwaldo Will Freeman added a comment - Andrew Bayer filed as JENKINS-48178
            Hide
            abayer Andrew Bayer added a comment - - edited

            Will Freeman Aaaaah. I thought of that and then forgot it because argh. Could you open another ticket against the workflow-cps-plugin component for currentBuild.result not picking up the junit status? Thanks.

            Show
            abayer Andrew Bayer added a comment - - edited Will Freeman Aaaaah. I thought of that and then forgot it because argh. Could you open another ticket against the workflow-cps-plugin component for currentBuild.result not picking up the junit status? Thanks.
            Hide
            therealwaldo Will Freeman added a comment - - edited

            Some time back, declarative pipelines were marking a stage as unstable, and I was able to have something like:

            pipeline {
              stage {
                steps {
                  sh 'runuittests'
                }
                post {
                  always {
                    junit 'junit.xml'
                  }
                }
              }
              stage {
                when {
                  expression {
                    currentBuild.resultIsBetterOrEqualTo('SUCCESS')
                  }
                }
                steps {
                  // Only runs when tests are stable
                }
              }
            }

            However, this stopped working at some point in the recent past.  I'm not sure what the cause was, but was hoping this ticket would resolve the issue.

            I have applied the latest update, but this is still not working.

            Andrew Bayer can you suggest how one might prevent, in a declarative manner or with an expression, a build stage from executing if the build is marked unstable in a previous stage?  Or is there still a bug present?

            Show
            therealwaldo Will Freeman added a comment - - edited Some time back, declarative pipelines were marking a stage as unstable, and I was able to have something like: pipeline { stage { steps { sh 'runuittests' } post { always { junit 'junit.xml' } } } stage { when { expression { currentBuild.resultIsBetterOrEqualTo( 'SUCCESS' ) } } steps { // Only runs when tests are stable } } } However, this stopped working at some point in the recent past.  I'm not sure what the cause was, but was hoping this ticket would resolve the issue. I have applied the latest update, but this is still not working. Andrew Bayer can you suggest how one might prevent, in a declarative manner or with an expression, a build stage from executing if the build is marked unstable in a previous stage?  Or is there still a bug present?
            Hide
            scm_issue_link SCM/JIRA link daemon added a comment -

            Code changed in jenkins
            User: Andrew Bayer
            Path:
            pipeline-model-definition/pom.xml
            pipeline-model-definition/src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/model/conditions/Aborted.groovy
            pipeline-model-definition/src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/model/conditions/Changed.groovy
            pipeline-model-definition/src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/model/conditions/Failure.groovy
            pipeline-model-definition/src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/model/conditions/NotBuilt.groovy
            pipeline-model-definition/src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/model/conditions/Success.groovy
            pipeline-model-definition/src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/model/conditions/Unstable.groovy
            pipeline-model-definition/src/test/java/org/jenkinsci/plugins/pipeline/modeldefinition/BuildConditionResponderTest.java
            pipeline-model-definition/src/test/resources/contextResultOverridesRunResult.groovy
            pipeline-model-definition/src/test/resources/junitResult.xml
            pipeline-model-extensions/src/main/java/org/jenkinsci/plugins/pipeline/modeldefinition/model/BuildCondition.java
            pom.xml
            http://jenkins-ci.org/commit/pipeline-model-definition-plugin/d533dd551dadca3d278f3c877aead9016d514b8c
            Log:
            [FIXED JENKINS-37663] Check execution result in post as well

            The new junit step doesn't set the Run to UNSTABLE directly, it sets
            the context (and therefore the execution) result to UNSTABLE. We
            should be checking the execution result as well as the Run result.

            Show
            scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Andrew Bayer Path: pipeline-model-definition/pom.xml pipeline-model-definition/src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/model/conditions/Aborted.groovy pipeline-model-definition/src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/model/conditions/Changed.groovy pipeline-model-definition/src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/model/conditions/Failure.groovy pipeline-model-definition/src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/model/conditions/NotBuilt.groovy pipeline-model-definition/src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/model/conditions/Success.groovy pipeline-model-definition/src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/model/conditions/Unstable.groovy pipeline-model-definition/src/test/java/org/jenkinsci/plugins/pipeline/modeldefinition/BuildConditionResponderTest.java pipeline-model-definition/src/test/resources/contextResultOverridesRunResult.groovy pipeline-model-definition/src/test/resources/junitResult.xml pipeline-model-extensions/src/main/java/org/jenkinsci/plugins/pipeline/modeldefinition/model/BuildCondition.java pom.xml http://jenkins-ci.org/commit/pipeline-model-definition-plugin/d533dd551dadca3d278f3c877aead9016d514b8c Log: [FIXED JENKINS-37663] Check execution result in post as well The new junit step doesn't set the Run to UNSTABLE directly, it sets the context (and therefore the execution) result to UNSTABLE. We should be checking the execution result as well as the Run result.
            Hide
            abayer Andrew Bayer added a comment -

            Releasing shortly in Declarative 1.2.5

            Show
            abayer Andrew Bayer added a comment - Releasing shortly in Declarative 1.2.5

              People

              • Assignee:
                abayer Andrew Bayer
                Reporter:
                joshma Joshua Ma
              • Votes:
                7 Vote for this issue
                Watchers:
                8 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: