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

currentBuild.result is not properly set to ABORTED when a build is aborted (withMaven)

      It appears that `currentBuild.result` is wrongly set to "FAILURE" when using `withMaven` plugin. If the build is aborted by the user during the execution of Maven, you would see the following in the console:

       

      [INFO] ------------------------------------------------------------------------
      sh: line 1:   155 Terminated              JENKINS_SERVER_COOKIE=$jsc '/home/jenkins/workspace/project_master-DI4KWP6GOIWKULYL6NTGKEGUMFUHD525PCW6NMP3YQUW3FXOIA4Q@tmp/durable-6a177cbc/script.sh' > '/home/jenkins/workspace/project_master-DI4KWP6GOIWKULYL6NTGKEGUMFUHD525PCW6NMP3YQUW3FXOIA4Q@tmp/durable-6a177cbc/jenkins-log.txt' 2>&1
      [Pipeline] }
      ERROR: [withMaven] WARNING logs generated by the Jenkins Maven Event Spy /home/jenkins/workspace/project_master-DI4KWP6GOIWKULYL6NTGKEGUMFUHD525PCW6NMP3YQUW3FXOIA4Q@tmp/withMaven1a80f4d8/maven-spy-20170709-113624-277.log are invalid, probably due to the interruption of the job, ignore file.
      ERROR: org.xml.sax.SAXParseException; lineNumber: 3267; columnNumber: 24; XML document structures must start and end within the same entity.
      [Pipeline] // withMaven
      [Pipeline] }
      [Pipeline] // stage
      [Pipeline] stage
      [Pipeline] { (Declarative: Post Actions)
      [Pipeline] script
      [Pipeline] {
      [Pipeline] echo
      currentBuild.result is: FAILURE
      [Pipeline] }
      [Pipeline] // script
      [Pipeline] deleteDir
      [Pipeline] }
      [Pipeline] // stage
      [Pipeline] }
      [Pipeline] // timeout
      [Pipeline] }
      [Pipeline] // node
      [Pipeline] End of Pipeline
      
      GitHub has been notified of this commit’s build result
      
      ERROR: script returned exit code 143
      Finished: ABORTED

       

      In the log above, we output `currentBuild.result` in the `post->always` section and it outputs "FAILURE" instead of "ABORTED", probably because the `withMaven` plugin is setting it. The build is properly marked as "ABORTED" at the end of the pipeline, but there is no way to make conditional checks for "ABORTED" builds in the `post->always` section. In our case, we wanted to ignore sending email notifications if the build was "ABORTED". 

      This seems to be related to #JENKINS-43339, however if you try a simple pipeline (like in the attached `works-fine.pipeline`) it works just fine. 

          [JENKINS-45385] currentBuild.result is not properly set to ABORTED when a build is aborted (withMaven)

          carlspring added a comment -

          Hi!

           

          When could we get some response on this issue? Is anybody looking into it?

           

          carlspring added a comment - Hi!   When could we get some response on this issue? Is anybody looking into it?  

            Unassigned Unassigned
            stodorov Steve Todorov
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: