Allow_failure:exit_codes does not behave as expected with powershell

Using a shell executor with powershell, allow_failure:exit_codes do not behave as documented

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 ?

Slightly related to How to mark stage as unstable if Powershell condition results into true? - #2 by OIiM.

@lorenzwalter : did you see the issue I’m talking about ?

Here is an example repo: Mathieu Westphal / exit_codes issue · GitLab

Thanks for creating the issue. I’ve linked this forum topic, and also a related issue with a workaround. GitLab CI: allow_failure:exit_codes does not behave as expected with powershell (#29127) · Issues · GitLab.org / gitlab-runner · GitLab

1 Like

I used the work around provided here: allow_failure:exit_codes unusable with windows shell executor because exit code is always 1 (#28244) · Issues · GitLab.org / gitlab-runner · GitLab

1 Like