diff options
author | Markus Doits <markus.doits@stellenticket.de> | 2018-10-24 23:22:10 +0300 |
---|---|---|
committer | Markus Doits <markus.doits@stellenticket.de> | 2018-11-07 15:05:22 +0300 |
commit | dfa8ab6f4219774104412c76b76c2716c44ccf3c (patch) | |
tree | 1b08ce7fc91ed32356810aac2fdbe1ce5ce30f21 /app/models | |
parent | 293c7b9e4164a2b224d6fcf80c402757130cff1f (diff) |
handle old retry format in build (possibly saved in database)
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/ci/build.rb | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/app/models/ci/build.rb b/app/models/ci/build.rb index 7b220487495..bebf356d1bf 100644 --- a/app/models/ci/build.rb +++ b/app/models/ci/build.rb @@ -317,12 +317,23 @@ module Ci pipeline.builds.retried.where(name: self.name).count end + # The format of the retry option changed in GitLab 11.5. Before it was an + # integer only, after it is a hash. New builds always created have the + # correct format, but builds created before GitLab 11.5 and saved in + # database still have the old integer only format. This helper method makes + # sure that the format is always correct when accessing the retry options, + # even on old builds. + def sanitized_retry_option + value = options&.[](:retry) + value.is_a?(Integer) ? { max: value } : value + end + def retries_max - options&.dig(:retry, :max) || 0 + sanitized_retry_option&.[](:max) || 0 end def retry_when - options&.dig(:retry, :when) || ['always'] + sanitized_retry_option&.[](:when) || ['always'] end def retry_failure? |