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

ExportXMLWordPrintable

      in a pipeline script it is common to catch errors and take action: notifications, gathering test reports of results thus far.

      This requires a dance around some variants of try/catch or try/finally, sometimes even rethrowing error, setting the currentBuild.result, checking of the currentBuild.result (to see if set previously). Othertimes you tell the test runner to not fail on test failures and set the build result to unstable (which then requires that you use more if/then or throwing exceptions as it will continue on if unstable for the rest of the pipeline script), and then accidentally deploy to production cough

      Would this be better to have a top level event handler?

      This could clarify the control throw without littering the script with non pipeline related flow controls for the case where there is a failure (and you want to exit but do some things). Likewise for notifications.

      onFailure {
         ... archive junit results
         ... notify teams
      }
      
      onSuccess {
          ... notify teams
      }
      

            Assignee:
            Jesse Glick
            Reporter:
            Michael Neale
            Archiver:
            Jenkins Service Account

              Created:
              Updated:
              Resolved:
              Archived: