Commit 9eed4a8d authored by Rémy Coutable's avatar Rémy Coutable

Merge branch 'fix-regression-in-handling-build-updated' into 'master'

Fix processing of events when build finished.

Update pipeline after processing builds. Otherwise we can get into scenario where pipeline will be marked as running.

This solves a quite significant regression in Pipeline processing.

Proper fix is to move all this to Sidekiq Worker and process pipeline there.
I'll do it after 8.12 release.

See merge request !6410
parents f30005f0 c826ad45
...@@ -242,6 +242,8 @@ module Ci ...@@ -242,6 +242,8 @@ module Ci
end end
def build_updated def build_updated
with_lock do
reload
case latest_builds_status case latest_builds_status
when 'pending' then enqueue when 'pending' then enqueue
when 'running' then run when 'running' then run
...@@ -251,6 +253,7 @@ module Ci ...@@ -251,6 +253,7 @@ module Ci
when 'skipped' then skip when 'skipped' then skip
end end
end end
end
def predefined_variables def predefined_variables
[ [
......
...@@ -69,15 +69,15 @@ class CommitStatus < ActiveRecord::Base ...@@ -69,15 +69,15 @@ class CommitStatus < ActiveRecord::Base
commit_status.update_attributes finished_at: Time.now commit_status.update_attributes finished_at: Time.now
end end
after_transition do |commit_status, transition|
commit_status.pipeline.try(:build_updated) unless transition.loopback?
end
after_transition any => [:success, :failed, :canceled] do |commit_status| after_transition any => [:success, :failed, :canceled] do |commit_status|
commit_status.pipeline.try(:process!) commit_status.pipeline.try(:process!)
true true
end end
after_transition do |commit_status, transition|
commit_status.pipeline.try(:build_updated) unless transition.loopback?
end
after_transition [:created, :pending, :running] => :success do |commit_status| after_transition [:created, :pending, :running] => :success do |commit_status|
MergeRequests::MergeWhenBuildSucceedsService.new(commit_status.pipeline.project, nil).trigger(commit_status) MergeRequests::MergeWhenBuildSucceedsService.new(commit_status.pipeline.project, nil).trigger(commit_status)
end end
......
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