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

This issue is archived. You can view it, but you can't modify it. Learn more

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?

            Assignee:
            Andrew Bayer
            Reporter:
            Adrien Lecharpentier
            Archiver:
            Jenkins Service Account

              Created:
              Updated:
              Resolved:
              Archived: