summaryrefslogtreecommitdiff
path: root/app/models/ci/pipeline.rb
diff options
context:
space:
mode:
authorLin Jen-Shin <godfat@godfat.org>2016-10-18 08:17:34 +0000
committerLin Jen-Shin <godfat@godfat.org>2016-10-18 08:17:34 +0000
commitac51fb888275fbb6c98f994ef1a9b3ace99decda (patch)
treeaca14b9b96e1f9a6283b8567dcd6b4137984ea2e /app/models/ci/pipeline.rb
parent0f21b1313b853d92b722b32ac25b8ad6a4860a63 (diff)
parent88d988a2edb5c56e9cb475a1db51bf8bb399f437 (diff)
downloadgitlab-ce-ac51fb888275fbb6c98f994ef1a9b3ace99decda.tar.gz
Merge branch 'pipeline-emails' into pipeline-notifications
* pipeline-emails: (58 commits) Update endpoint to username validator change border color to variable Add todo for deprecated user routes and more information about deprecation to changelog Provide better error message to the user Apply better hierarchy to markdown headers and issue/mr titles Swapped button text manipulation outcomes for the toggle query Fixed find file keyboard navigation Update CHANGELOG for 8.12.7 Added download-button class and applied button margin Enable activerecord_sane_schema_dumper for test Updated logo from @luke Fix broken specs on MySQL after https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/6896 Fix Test Env (proper error handling when gitlab-shell is not clonned) Fix randomly crashing spinach test for merge request [Great spinach fix] Replace gsub with delete Remove carriage returns from commit description as summary is on a newline and will always include carriage returns Convert due_date_select.js filetype to es6. Stop directly parsing due_date with Date.parse, prefer parsing implicitly. Improve spec for pipeline metrics worker Add Pipeline metrics worker ...
Diffstat (limited to 'app/models/ci/pipeline.rb')
-rw-r--r--app/models/ci/pipeline.rb10
1 files changed, 6 insertions, 4 deletions
diff --git a/app/models/ci/pipeline.rb b/app/models/ci/pipeline.rb
index 5604296cba5..941b01c29e0 100644
--- a/app/models/ci/pipeline.rb
+++ b/app/models/ci/pipeline.rb
@@ -49,6 +49,10 @@ module Ci
transition any => :canceled
end
+ # IMPORTANT
+ # Do not add any operations to this state_machine
+ # Create a separate worker for each new operation
+
before_transition [:created, :pending] => :running do |pipeline|
pipeline.started_at = Time.now
end
@@ -62,13 +66,11 @@ module Ci
end
after_transition [:created, :pending] => :running do |pipeline|
- MergeRequest::Metrics.where(merge_request_id: pipeline.merge_requests.map(&:id)).
- update_all(latest_build_started_at: pipeline.started_at, latest_build_finished_at: nil)
+ pipeline.run_after_commit { PipelineMetricsWorker.perform_async(id) }
end
after_transition any => [:success] do |pipeline|
- MergeRequest::Metrics.where(merge_request_id: pipeline.merge_requests.map(&:id)).
- update_all(latest_build_finished_at: pipeline.finished_at)
+ pipeline.run_after_commit { PipelineMetricsWorker.perform_async(id) }
end
after_transition [:created, :pending, :running] => :success do |pipeline|