Make it possible to control build status using exit codes
We've open a separate issue #273157 (closed) to explore additional ways on how to solve this issue - Please add your comments to this issue only if the proposed solution does not fit your needs
It may be an interesting feature to be able to control build status using
.gitlab-ci.yml and exit codes.
Implement control for exit codes as follows, based on the list of possible ones that are supported (failed, warning, success):
my-job: script: - echo Hello world! script_exit_codes: success: [0, 1, 2] warning: [7, 14] canceled:  # anything else is failed
script_exit_codes are applied to the job based on the first non-zero exit code encountered in the script, or the last zero if all exit codes were zero.
success:is not defined, it is evaluated as
success: . If it is defined, and you want 0 to be a success, it must be included in your array.
warning:is not defined, it is evaluated as
canceled:is not defined, it is evaluated as
- If a job is set to
allow_failure: true, all failure states will be also treated as warnings.
The following configuration should be considered invalid and a syntax error should be returned because of duplicate values (
1 in this case). Both
warning should have mutually exclusive values.
my-job: script: - echo Hello world! script_exit_codes: success: [0, 1, 2] warning: 
It would be used by https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/8121
Idea from @ayufan during Slack conversation :)
script_exit_codesto the YAML keywords
- Add support for
canceledstate. This should already be done as part of gitlab-runner#4843
- The runner should compare the exit code with the ones defined in
script_exit_codes(if available) before sending the status.
This page may contain information related to upcoming products, features and functionality. It is important to note that the information presented is for informational purposes only, so please do not rely on the information for purchasing or planning purposes. Just like with all projects, the items mentioned on the page are subject to change or delay, and the development, release, and timing of any products, features, or functionality remain at the sole discretion of GitLab Inc.