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

Timeout is caught by the most internal try-catch, but should be caught by the try-catch that surrounds the timeout step

    XMLWordPrintable

    Details

    • Similar Issues:

      Description

      Simple example:

      node('master') {
        try {
          timeout(time: 5, unit: 'SECONDS') {
            try {
              sleep(30)
            }
            catch (err) {
              echo "For some reason, this catch is activated. Error: ${err.getMessage()}"
            }
            echo "This should not be executed, but it is!"
          }
        }
        catch (err) {
          echo "I expect that this catch will be activated. Error: ${err.getMessage()}"
        }
      }
      

      I expect that when a timeout is reached, the exception will be caught by the try-catch that surrounds the "timeout" step.
      But actually, it is caught by the most inner try-catch.
      My goal here is to set timeout to set of actions and if the timeout is reached, I want them all to stop. I also want to have more try-catch inside for handling other issues.
      But the actual behavior is that when the timeout is reached, the most internal catch handles it instead of the try-catch that surrounds the timeout step.

      This issue is similar to JENKINS-39266. I do not understand why it was closed.

      By the way, the 

      err.getMessage()

      prints "null", which is also a problem.

        Attachments

          Issue Links

            Activity

            erez_arbell Erez Arbell created issue -
            oleg_nenashev Oleg Nenashev made changes -
            Field Original Value New Value
            Component/s pipeline [ 21692 ]
            Component/s groovy-plugin [ 15549 ]
            oleg_nenashev Oleg Nenashev made changes -
            Assignee vjuranek [ vjuranek ]
            miraha jang hyemi (Inactive) made changes -
            Status Open [ 1 ] In Progress [ 3 ]
            abayer Andrew Bayer made changes -
            Component/s workflow-basic-steps-plugin [ 21712 ]
            Component/s pipeline [ 21692 ]
            dnusbaum Devin Nusbaum made changes -
            Link This issue relates to JENKINS-40839 [ JENKINS-40839 ]
            vivek Vivek Pandey made changes -
            Labels Groovy catch timeout try Groovy catch timeout triaged-2018-11 try
            jglick Jesse Glick made changes -
            Status In Progress [ 3 ] Open [ 1 ]
            jglick Jesse Glick made changes -
            Link This issue relates to JENKINS-28822 [ JENKINS-28822 ]
            jglick Jesse Glick made changes -
            Resolution Not A Defect [ 7 ]
            Status Open [ 1 ] Resolved [ 5 ]
            dnusbaum Devin Nusbaum made changes -
            Link This issue relates to JENKINS-51454 [ JENKINS-51454 ]

              People

              Assignee:
              Unassigned Unassigned
              Reporter:
              erez_arbell Erez Arbell
              Votes:
              1 Vote for this issue
              Watchers:
              6 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: