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

XMLWordPrintable

    • Type: Improvement
    • Resolution: Unresolved
    • Priority: Major
    • Component/s: powershell-plugin
    • None
    • Environment:
      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).

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

              Created:
              Updated: