Windows Shared Runner - Powershell $ErrorActionPreference not working
Summary
Job behaviour not working as expected on Window Shared Runners.
When setting $ErrorActionPreference
to Stop
we should expect the job to fail when encountering any errors, but we do not:
When setting $ErrorActionPreference
to Continue
(default) or not setting it at all we should expect the job to succeed when encountering any non-terminating errors, but we do not:
Steps to reproduce
Run this pipeline on a shared runner:
.gitlab-ci.yml
stages:
- test
.shared_windows_runners:
tags:
- shared-windows
- windows
- windows-1809
Terminating:
extends: .shared_windows_runners
stage: test
variables:
ErrorActionPreference: Continue
script:
- echo ${ErrorActionPreference}
- Get-InstalledModule
- NONEXISTANTCMDLET
Non-terminating:
extends: .shared_windows_runners
stage: test
variables:
ErrorActionPreference: Stop
script:
- echo ${ErrorActionPreference}
- Get-InstalledModule
- NONEXISTANTCMDLET
Terminating_2:
extends: .shared_windows_runners
stage: test
script:
- $ErrorActionPreference = 'Continue'
- Get-InstalledModule
- NONEXISTANTCMDLET
Non-terminating_2:
extends: .shared_windows_runners
stage: test
script:
- $ErrorActionPreference = 'Stop'
- Get-InstalledModule
- NONEXISTANTCMDLET
Actual behavior
When defining the $ErrorActionPreference
to stop
it allows terminating errors to continue
.
When defining the $ErrorActionPreference
to Continue
it allows terminating errors to stop
.
Expected behavior
When defining the $ErrorActionPreference
to stop
it allows terminating errors to stop
.
When defining the $ErrorActionPreference
to Continue
it allows terminating errors to continue
.
Relevant logs and/or screenshots
job log
Please see job logs in test project (internal)
Environment description
Using Shared Runners on GitLab.com .
Used GitLab Runner version
Running with gitlab-runner 15.8.2 (4d1ca121)
on windows-shared-runners-manager 6QgxEPvR, system ID: s_1a31f6141cb7
-->