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,13 +242,16 @@ module Ci
end
def build_updated
case latest_builds_status
when 'pending' then enqueue
when 'running' then run
when 'success' then succeed
when 'failed' then drop
when 'canceled' then cancel
when 'skipped' then skip
with_lock do
reload
case latest_builds_status
when 'pending' then enqueue
when 'running' then run
when 'success' then succeed
when 'failed' then drop
when 'canceled' then cancel
when 'skipped' then skip
end
end
end
......
......@@ -69,15 +69,15 @@ class CommitStatus < ActiveRecord::Base
commit_status.update_attributes finished_at: Time.now
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|
commit_status.pipeline.try(:process!)
true
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|
MergeRequests::MergeWhenBuildSucceedsService.new(commit_status.pipeline.project, nil).trigger(commit_status)
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