Skip to content
Snippets Groups Projects

Implement exit code functionality for allow_failure

Merged Marius Bobin requested to merge ci-implement-exit-code-functionality into master
Files
6
+ 23
0
@@ -1031,6 +1031,13 @@ def debug_mode?
variables.any? { |variable| variable[:key] == 'CI_DEBUG_TRACE' && variable[:value].casecmp('true') == 0 }
end
def drop_with_exit_code!(failure_reason, exit_code)
transaction do
conditionally_allow_failure!(exit_code)
drop!(failure_reason)
end
end
protected
def run_status_commit_hooks!
@@ -1114,6 +1121,22 @@ def job_jwt_variables
Gitlab::ErrorTracking.track_exception(e)
end
end
def conditionally_allow_failure!(exit_code)
return unless ::Gitlab::Ci::Features.allow_failure_with_exit_codes_enabled?
return unless exit_code
if allowed_to_fail_with_code?(exit_code)
update_columns(allow_failure: true)
end
end
def allowed_to_fail_with_code?(exit_code)
options
.dig(:allow_failure_criteria, :exit_codes)
.to_a
.include?(exit_code)
end
end
end
Loading