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

Windows Powershell plugin should catch exceptions

XMLWordPrintable

      v1.3 added the ability to catch the last exit code of the configured commands but if a command is missing and Powershell throws an exception, PS doesn't set $LastExitCode and the build succeeds. Rather than emit:

      {{
      <user's configured commands>
      exit $LastExitCode
      }}

      It would be helpful to do:

      {{
      try

      { <user's configured commands> exit $LastExitCode } catch { write-host "Script threw an exception" write-host $error[0] exit 1 } }}

      (or something). See MSDN and StackOverflow

            Unassigned Unassigned
            chrisnelsonpe Chris Nelson
            Votes:
            1 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: