I'm using docker to run a program as part of the CI/CD process. at the program, if the exit code is 2 I don't want the CI/CD to fail and only get a warning.
added this to the gitlab-ci.yml file:
allow_failure:
exit_codes:
- 2
but even tho the docker exit code is (2) at the pipeline I'm getting ERROR: Job failed: exit code 1
How can I change the error code of the pipeline to be like as the docker error code?
Thanks.
With the
allow_failure
keyword, your job is allowed to fail. It means that it won't failed if the specified exit_code resulted.Your job will still have an exit code, but it will be marked in
warning
in your pipeline instead offailed
As an example, I made a simple job :
After adding the last two line, the pipeline moved to status
warning
: See pipeline pictureHope it helps you!
You can find more information here : https://docs.gitlab.com/ee/ci/yaml/#allow_failure