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

The error step is not setting the currentBuild.result nor currentBuild.currentResult

XMLWordPrintable

      When using error 'foo' in a scripted pipeline, it seems that the currentBuild.result or currentBuild.currentResult are not set accordingly. Here is a simple reproductible script:

      node {
        try {
          echo currentBuild.currentResult
          error 'foo'
        } finally {
          echo currentBuild.currentResult
        }
      }

      and the output isĀ 

      [Pipeline] node
      Running on master in /tmp/jenkins-home/workspace/foo
      [Pipeline] {
      [Pipeline] echo
      SUCCESS
      [Pipeline] error
      [Pipeline] echo
      SUCCESS
      [Pipeline] }
      [Pipeline] // node
      [Pipeline] End of Pipeline
      ERROR: foo
      Finished: FAILURE

      Is this because, in the finally block, the "exception" thrown by error happened but it not yet handled to quite the execution of the currentBuild?

            abayer Andrew Bayer
            alecharp Adrien Lecharpentier
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: