diff options
author | Markus Doits <markus.doits@stellenticket.de> | 2018-09-15 15:02:43 +0300 |
---|---|---|
committer | Markus Doits <markus.doits@stellenticket.de> | 2018-11-07 15:00:39 +0300 |
commit | 007db85dd4e4c92e060160427429c4fb2ad5cb32 (patch) | |
tree | cfa5202a504dcb7a944556bb5c286997d82d280e /app | |
parent | 473b52b2837bfffc634f574f148d949e218137ed (diff) |
add `retry_failure?` option and use it to decide if to retry a build failure
Diffstat (limited to 'app')
-rw-r--r-- | app/models/ci/build.rb | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/app/models/ci/build.rb b/app/models/ci/build.rb index b133c756fcf..592b784807c 100644 --- a/app/models/ci/build.rb +++ b/app/models/ci/build.rb @@ -220,9 +220,7 @@ module Ci build.deployment&.drop - next if build.retries_max.zero? - - if build.retries_count < build.retries_max + if build.retry_failure? begin Ci::Build.retry(build, build.user) rescue Gitlab::Access::AccessDeniedError => ex @@ -329,6 +327,19 @@ module Ci retries.is_a?(Hash) && retries.fetch(:when, 'always').to_s || 'always' end + def retry_failure? + return false if retries_max.zero? || retries_count >= retries_max + + case failure_reason.to_s + when 'runner_system_failure' + %['always', 'system failure'].include?(retry_when) + when 'script_failure' + %['always', 'script failure'].include?(retry_when) + else + retry_when == 'always' + end + end + def latest? !retried? end |