Commit a34a8765 authored by Mayra Cabrera's avatar Mayra Cabrera

Merge branch 'sh-coerce-options-retry-integer' into 'master'

Coerce CI auto_retry max value to an integer

Closes #233035

See merge request gitlab-org/gitlab!38331
parents 1ae56f36 b3b5c808
......@@ -30,7 +30,7 @@ class Gitlab::Ci::Build::AutoRetry
end
def options_retry_max
options_retry[:max] if retry_on_reason_or_always?
Integer(options_retry[:max], exception: false) if retry_on_reason_or_always?
end
def options_retry_when
......
......@@ -16,6 +16,7 @@ RSpec.describe Gitlab::Ci::Build::AutoRetry do
"retries are disabled" | 0 | { max: 0 } | nil | false
"max equals count" | 2 | { max: 2 } | nil | false
"max is higher than count" | 1 | { max: 2 } | nil | true
"max is a string" | 1 | { max: '2' } | nil | true
"matching failure reason" | 0 | { when: %w[api_failure], max: 2 } | :api_failure | true
"not matching with always" | 0 | { when: %w[always], max: 2 } | :api_failure | true
"not matching reason" | 0 | { when: %w[script_error], max: 2 } | :api_failure | false
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment