Search code examples
gitlabyamlgitlab-cigitlab-ci-runner

GitLab job allow failure on certain exit code


I have a GitLab CI/CD job doing some stuff.

I want some executed commands to be able to fail and result in a warning for this job, but I also want other command to result in an error in the pipeline if they fail.

I have set in the .yaml file allow_failure: true, which will always result in a warning for this job regardless of the error.

Can I tell GitLab job to output an error for a specific exit code and a warning for another ?


Solution

  • With gitlab 13.9 allow_failure:exit_codes were introduced. With that you can now allow failure for certain exit codes and fail the job for all other ones.

      allow_failure:
        exit_codes:
          - 137
          - 255