diff options
author | Phil Hughes <me@iamphill.com> | 2017-07-24 14:36:31 +0100 |
---|---|---|
committer | Phil Hughes <me@iamphill.com> | 2017-07-24 14:36:31 +0100 |
commit | 4d2be5bbec25d60a8d478bda5bc83159f2c845b1 (patch) | |
tree | c3c28a833ccd2a6628d928acee44e62ccfcc6fd8 /app/models/ci/build.rb | |
parent | 1a2d180e3dfd8bdad94766a2e8b1195288c2b146 (diff) | |
parent | d4c4dec80dc3abd39116440a3c291c19b27258e1 (diff) | |
download | gitlab-ce-4d2be5bbec25d60a8d478bda5bc83159f2c845b1.tar.gz |
Merge branch 'master' into sidebar-fly-out-sub-nav
Diffstat (limited to 'app/models/ci/build.rb')
-rw-r--r-- | app/models/ci/build.rb | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/app/models/ci/build.rb b/app/models/ci/build.rb index 432f3f242eb..416a2a33378 100644 --- a/app/models/ci/build.rb +++ b/app/models/ci/build.rb @@ -96,6 +96,14 @@ module Ci BuildSuccessWorker.perform_async(id) end end + + before_transition any => [:failed] do |build| + next if build.retries_max.zero? + + if build.retries_count < build.retries_max + Ci::Build.retry(build, build.user) + end + end end def detailed_status(current_user) @@ -130,6 +138,14 @@ module Ci success? || failed? || canceled? end + def retries_count + pipeline.builds.retried.where(name: self.name).count + end + + def retries_max + self.options.fetch(:retry, 0).to_i + end + def latest? !retried? end |