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

`currentBuild.result` is not set to `ABORTED` when the build was aborted

      Right now when the build is aborted using the `pipeline-input-step` plugin in a declarative pipeline, the build result is set to `FAILURE` instead of `ABORTED` in the post section. However, the actual result is properly set to `ABORTED` afterwards. This makes it impossible to do conditional code in the post section.

          [JENKINS-43339] `currentBuild.result` is not set to `ABORTED` when the build was aborted

          Roch Devost created issue -

          Roch Devost added a comment -

          It seems this is also true for `SUCCESS` which is set only after the build has completed (and after all post sections), but using `currentBuild.result` inside of a post section returns `null`.

          Roch Devost added a comment - It seems this is also true for `SUCCESS` which is set only after the build has completed (and after all post sections), but using `currentBuild.result` inside of a post section returns `null`.

          Jo Carter added a comment -

          This also happens for builds that are Superseded (when using milestones).  When I get the current result status in the failure block it says "FAILURE" but the build final status is NOT_BUILT. (Same for ABORTED as above).

          It's also incorrectly reporting as a completeBuild - which is an additional check that I'm performing.

          Getting the previous build does return the correct result.

          Jo Carter added a comment - This also happens for builds that are Superseded (when using milestones).  When I get the current result status in the failure block it says "FAILURE" but the build final status is NOT_BUILT. (Same for ABORTED as above). It's also incorrectly reporting as a completeBuild - which is an additional check that I'm performing. Getting the previous build does return the correct result.

          Andrew Bayer added a comment -

          Interesting! We're setting the build result to FAILURE explicitly when we encounter an exception in execution of a stage, but I'm guessing that's not the ideal behavior for these scenarios. I'll investigate.

          Andrew Bayer added a comment - Interesting! We're setting the build result to FAILURE explicitly when we encounter an exception in execution of a stage, but I'm guessing that's not the ideal behavior for these scenarios. I'll investigate.

          Jo Carter added a comment -

          Thank you

          Jo Carter added a comment - Thank you
          Andrew Bayer made changes -
          Status Original: Open [ 1 ] New: In Progress [ 3 ]
          Andrew Bayer made changes -
          Status Original: In Progress [ 3 ] New: In Review [ 10005 ]

          Andrew Bayer added a comment -

          Andrew Bayer added a comment - Tada - PR up at https://github.com/jenkinsci/pipeline-model-definition-plugin/pull/153 .
          Andrew Bayer made changes -
          Remote Link New: This issue links to "PR #153 (Web Link)" [ 16227 ]

          Code changed in jenkins
          User: Andrew Bayer
          Path:
          pipeline-model-definition/pom.xml
          pipeline-model-definition/src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/Utils.groovy
          pipeline-model-definition/src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/model/conditions/NotBuilt.groovy
          pipeline-model-definition/src/main/resources/org/jenkinsci/plugins/pipeline/modeldefinition/ModelInterpreter.groovy
          pipeline-model-definition/src/main/resources/org/jenkinsci/plugins/pipeline/modeldefinition/agent/impl/DockerPipelineFromDockerfileScript.groovy
          pipeline-model-definition/src/main/resources/org/jenkinsci/plugins/pipeline/modeldefinition/agent/impl/DockerPipelineScript.groovy
          pipeline-model-definition/src/main/resources/org/jenkinsci/plugins/pipeline/modeldefinition/agent/impl/LabelScript.groovy
          pipeline-model-definition/src/main/resources/org/jenkinsci/plugins/pipeline/modeldefinition/model/conditions/Messages.properties
          pipeline-model-definition/src/test/java/org/jenkinsci/plugins/pipeline/modeldefinition/BasicModelDefTest.java
          pom.xml
          http://jenkins-ci.org/commit/pipeline-model-definition-plugin/d9a8fb10d9c830470dfb9871696ca9df8c50f0f7
          Log:
          [FIXED JENKINS-43339] Properly set result from FlowInterruptedException

          We should be setting the build result to
          FlowInterruptedException.getResult() when we catch a
          FlowInterruptedException, since there's actually a relevant result
          there. Also added a notBuilt post status while I was here.

          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/Utils.groovy pipeline-model-definition/src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/model/conditions/NotBuilt.groovy pipeline-model-definition/src/main/resources/org/jenkinsci/plugins/pipeline/modeldefinition/ModelInterpreter.groovy pipeline-model-definition/src/main/resources/org/jenkinsci/plugins/pipeline/modeldefinition/agent/impl/DockerPipelineFromDockerfileScript.groovy pipeline-model-definition/src/main/resources/org/jenkinsci/plugins/pipeline/modeldefinition/agent/impl/DockerPipelineScript.groovy pipeline-model-definition/src/main/resources/org/jenkinsci/plugins/pipeline/modeldefinition/agent/impl/LabelScript.groovy pipeline-model-definition/src/main/resources/org/jenkinsci/plugins/pipeline/modeldefinition/model/conditions/Messages.properties pipeline-model-definition/src/test/java/org/jenkinsci/plugins/pipeline/modeldefinition/BasicModelDefTest.java pom.xml http://jenkins-ci.org/commit/pipeline-model-definition-plugin/d9a8fb10d9c830470dfb9871696ca9df8c50f0f7 Log: [FIXED JENKINS-43339] Properly set result from FlowInterruptedException We should be setting the build result to FlowInterruptedException.getResult() when we catch a FlowInterruptedException, since there's actually a relevant result there. Also added a notBuilt post status while I was here.

            abayer Andrew Bayer
            rochdev Roch Devost
            Votes:
            6 Vote for this issue
            Watchers:
            27 Start watching this issue

              Created:
              Updated:
              Resolved: