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

An error in a "finally" block will result in squelching the original exception thrown

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Minor Minor
    • workflow-cps-plugin
    • None

      Considering the following contrived Jenkinsfile:

      node {
          try {
              echo "I'm too cool to stash"
              1 / 0 
          }
      finally {
              unstash 'invalid'
              echo "Did you see the exception?"
          }
      }
      

      The exception thrown in the try block will never ever get printed in the Console Output. This is pretty frustrating as it hides the original error from me :'(, see below:

      Started by user admin
      Replayed #3
      [Pipeline] node
      Running on master in /var/jenkins_home/workspace/foo
      [Pipeline] {
      [Pipeline] echo
      I'm too cool to stash
      [Pipeline] unstash
      [Pipeline] }
      [Pipeline] // node
      [Pipeline] End of Pipeline
      ERROR: No such saved stash ‘invalid’
      Finished: FAILURE
      

          [JENKINS-45379] An error in a "finally" block will result in squelching the original exception thrown

          R. Tyler Croy created issue -
          Andrew Bayer made changes -
          Status Original: Open [ 1 ] New: In Progress [ 3 ]
          Andrew Bayer made changes -
          Status Original: In Progress [ 3 ] New: Open [ 1 ]
          Jesse Glick made changes -
          Component/s New: workflow-cps-plugin [ 21713 ]
          Component/s Original: pipeline [ 21692 ]
          Andrew Bayer made changes -
          Assignee Original: Andrew Bayer [ abayer ]

            Unassigned Unassigned
            rtyler R. Tyler Croy
            Votes:
            2 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated: