Commit de61efed authored by Kamil Trzcinski's avatar Kamil Trzcinski

Fix processing of events when build finished.

This solves Pipelines in `running` after all stages do finish.
parent c20e4267
...@@ -241,13 +241,15 @@ module Ci ...@@ -241,13 +241,15 @@ module Ci
end end
def build_updated def build_updated
case latest_builds_status with_lock do
when 'pending' then enqueue case reload.latest_builds_status
when 'running' then run when 'pending' then enqueue
when 'success' then succeed when 'running' then run
when 'failed' then drop when 'success' then succeed
when 'canceled' then cancel when 'failed' then drop
when 'skipped' then skip when 'canceled' then cancel
when 'skipped' then skip
end
end end
end end
......
...@@ -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