diff options
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/ci/build.rb | 5 | ||||
-rw-r--r-- | app/models/ci/commit.rb | 10 |
2 files changed, 13 insertions, 2 deletions
diff --git a/app/models/ci/build.rb b/app/models/ci/build.rb index 89af83d8efc..f35224916ed 100644 --- a/app/models/ci/build.rb +++ b/app/models/ci/build.rb @@ -50,6 +50,7 @@ module Ci scope :latest, ->() { where(id: unscope(:select).select('max(id)').group(:name)).order(stage_idx: :asc) } scope :ignore_failures, ->() { where(allow_failure: false) } scope :for_ref, ->(ref) { where(ref: ref) } + scope :similar, ->(build) { where(ref: build.ref, tag: build.tag, trigger_request_id: build.trigger_request_id) } acts_as_taggable @@ -125,8 +126,8 @@ module Ci Ci::WebHookService.new.build_end(build) end - if build.commit.success? - build.commit.create_next_builds(build.trigger_request) + if build.commit.should_create_next_builds?(build) + build.commit.create_next_builds(build.ref, build.tag, build.user, build.trigger_request) end project.execute_services(build) diff --git a/app/models/ci/commit.rb b/app/models/ci/commit.rb index 31da7e8f2b6..c77921979a6 100644 --- a/app/models/ci/commit.rb +++ b/app/models/ci/commit.rb @@ -224,6 +224,16 @@ module Ci update!(committed_at: DateTime.now) end + def should_create_next_builds?(build) + # don't create other builds if this one is retried + other_builds = builds.similar(build).latest + return false unless other_builds.include?(build) + + other_builds.all? do |build| + build.success? || build.ignored? + end + end + private def save_yaml_error(error) |