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

Add $ErrorActionPreference = "Stop" to the top of each script before executing

XMLWordPrintable

    • Icon: Improvement Improvement
    • Resolution: Unresolved
    • Icon: Major Major
    • powershell-plugin
    • None
    • Jenkins 1.628
      powershell-plugin 1.2

      Just as bash scripts are executed with set -e (as to terminate on any error), so should PowerShell scripts be executed with $ErrorActionPreference = "Stop" at the top (to the same effect).

      Not only is it more consistent (e.g. with bash), it is also usually a more desirable behavior in CI scenarios (when you allow the script to continue you can miss important silent errors).

      A user can always start his script with $ErrorActionPreference = "Continue" to override this, or it could be a checkbox, or the user could simply wrap potentially erronous statements in a try-catch block (probably the best solution).

            Unassigned Unassigned
            ohadschn Ohad Schneider
            Votes:
            5 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated: