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

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

    XMLWordPrintable

Details

    Description

      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.

      Attachments

        Issue Links

          Activity

            kutzi kutzi added a comment - - edited

            Is there not a reliable way to get from the rawBuild if a build was aborted?
            I cannot image that there's no way - as the builds are eventually - when they are totally finished - always displayed with the right result. 'Only' currentBuild.currentResult is very often giving a different result (FAILURE usually)
            We're using this hack now to get better detection of aborted builds:

            if (currentBuild.rawBuild.getActions(jenkins.model.InterruptedBuildAction.class).isEmpty()) {
               return currentBuild.currentResult
            } else {
              return "ABORTED"
            }
            
            kutzi kutzi added a comment - - edited Is there not a reliable way to get from the rawBuild if a build was aborted? I cannot image that there's no way - as the builds are eventually - when they are totally finished - always displayed with the right result. 'Only' currentBuild.currentResult is very often giving a different result (FAILURE usually) We're using this hack now to get better detection of aborted builds: if (currentBuild.rawBuild.getActions(jenkins.model.InterruptedBuildAction.class).isEmpty()) { return currentBuild.currentResult } else { return "ABORTED" }
            bitwiseman Liam Newman added a comment -

            Bulk closing resolved issues.

            bitwiseman Liam Newman added a comment - Bulk closing resolved issues.

            Thanks kutzi – this workaround is indeed very helpful! (Of course one would prefer a proper/clean solution/fix... )

            reinholdfuereder Reinhold Füreder added a comment - Thanks kutzi – this workaround is indeed very helpful! (Of course one would prefer a proper/clean solution/fix... )
            kutzi kutzi added a comment - - edited

            reinholdfuereder according to your comment, you still have experienced this issue in the current release?
            I'm having the workaround in place and therefore not watching it anymore.
            According to Liam's comment this should have been fixed?

            kutzi kutzi added a comment - - edited reinholdfuereder  according to your comment, you still have experienced this issue in the current release? I'm having the workaround in place and therefore not watching it anymore. According to Liam's comment this should have been fixed?
            aspiridonovs Aleksejs added a comment -

            Jenkins 2.375.1, manually aborted build had `currentBuild.currentResult`= success, sending notification as such. Workaround helped. 

            aspiridonovs Aleksejs added a comment - Jenkins 2.375.1, manually aborted build had `currentBuild.currentResult`= success, sending notification as such. Workaround helped. 

            People

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

              Dates

                Created:
                Updated:
                Resolved: