diff options
author | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2016-10-04 12:25:06 +0200 |
---|---|---|
committer | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2016-10-04 14:43:58 +0200 |
commit | f57cfdb6b527fe20f64f8a76339264948c3b358b (patch) | |
tree | a75b36b023086ca07c83a280abaa810dbc38647e /app/models/commit_status.rb | |
parent | ebeee31100cb142dfc74ec02928d3c5433eab8d7 (diff) | |
download | gitlab-ce-f57cfdb6b527fe20f64f8a76339264948c3b358b.tar.gz |
Update order of build transition callbacks
Diffstat (limited to 'app/models/commit_status.rb')
-rw-r--r-- | app/models/commit_status.rb | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/app/models/commit_status.rb b/app/models/commit_status.rb index 09aec6b40d0..9c4f86144d8 100644 --- a/app/models/commit_status.rb +++ b/app/models/commit_status.rb @@ -69,27 +69,28 @@ class CommitStatus < ActiveRecord::Base commit_status.update_attributes finished_at: Time.now end - after_transition [:created, :pending, :running] => :success do |commit_status| - MergeRequests::MergeWhenBuildSucceedsService.new(commit_status.pipeline.project, nil).trigger(commit_status) - end - - after_transition any => :failed do |commit_status| - MergeRequests::AddTodoWhenBuildFailsService.new(commit_status.pipeline.project, nil).execute(commit_status) - end - after_transition do |commit_status, transition| - return if transition.loopback? + commit_status.pipeline.tap do |pipeline| + return if transition.loopback? + return unless pipeline - commit_status.pipeline.try(:id).try do |pipeline_id| if commit_status.complete? - ProcessPipelineWorker.perform_async(pipeline_id) + ProcessPipelineWorker.perform_async(pipeline.id) end - UpdatePipelineWorker.perform_async(pipeline_id) + UpdatePipelineWorker.perform_async(pipeline.id) end true end + + after_transition [:created, :pending, :running] => :success do |commit_status| + MergeRequests::MergeWhenBuildSucceedsService.new(commit_status.pipeline.project, nil).trigger(commit_status) + end + + after_transition any => :failed do |commit_status| + MergeRequests::AddTodoWhenBuildFailsService.new(commit_status.pipeline.project, nil).execute(commit_status) + end end delegate :sha, :short_sha, to: :pipeline |