Using a shell executor with powershell, allow_failure:exit_codes do not behave as documented https://docs.gitlab.com/ee/ci/yaml/#allow_failureexit_codes
With the following very simple job:
build:
script:
- exit 4
allow_failure:
exit_codes:
- 4
The job fails instead of passing with a warning sign.
It works perfectly with bash.
it works perfectly with allow_failure: true
.
Am I missing something ? Is there a work around ?
CodePudding user response:
This is an aspect of how Powershell works, in general. See: Returning an exit code from a PowerShell script
To workaround this for a shell executor running powershell, use the following:
script:
- $host.SetShouldExit(4); exit 4
# ...
Note, however this workaround may not work for custom executors, like the beta shared-windows
autoscaling executors on gitlab.com -- there is no workaround in that case at this time of writing.