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

Stage block syntax results in aborted builds to be shown as failed

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Minor Minor
    • None
    • Tested with:
       * Jenkins 2.32.3 and 2.37
       * Pipeline: Stage Step: 2.2

      Aborting the build manually or via an input step results in state Failed instead of state Aborted. This creates a misleading visualization of the project, where users will be lead to believe the project is unstable.

      Steps to reproduce
      Use the following Jenkinsfile

      node {
        stage ('Sleep') { sleep 60 }
      }
      

      Start a build and abort it while it's sleeping. The job output:

      Sleeping for 1 min 0 sec
      Aborted by user
      GitHub has been notified of this commit’s build result
      Finished: ABORTED
      

      While the status is logged as Aborted, the job is shown as Failed:

      Workaround
      Use the old stage syntax instead of the new block syntax:

      node {
        stage 'Sleep'
        sleep 60
      }
      

      Aborting this job while sleeping yields the following log:

      Using the ‘stage’ step without a block argument is deprecated
      Entering stage Sleep
      Proceeding
      Sleeping for 1 min 0 sec
      Aborted by user
      GitHub has been notified of this commit’s build result
      Finished: ABORTED
      

      This time the job status is correctly shown as Aborted:

      Why this is important
      1. It erodes user confidence in projects that are erroneously marked as Failed
      2. It encourages users to write Jenkinsfiles using the legacy Stage syntax

          [JENKINS-43036] Stage block syntax results in aborted builds to be shown as failed

          bwijsmuller added a comment -

          Workaround is to catch FlowInterruptedException and set currentBuild.result = 'SUCCESS'

          I would prefer to not do this.

          bwijsmuller added a comment - Workaround is to catch FlowInterruptedException and set currentBuild.result = 'SUCCESS' I would prefer to not do this.

          We have the same problem, as we have a lot of aborted jobs a fix for this is highly appreciated!

          Till Steinbach added a comment - We have the same problem, as we have a lot of aborted jobs a fix for this is highly appreciated!

            Unassigned Unassigned
            mpavlov mpavlov
            Votes:
            4 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated: