From 3e60d62cc39b512fa1ac6b419815e88a6f6e1224 Mon Sep 17 00:00:00 2001 From: Grzegorz Bizon Date: Tue, 26 Sep 2017 11:13:40 +0200 Subject: Add class that handles pipeline creation sequence --- app/services/ci/create_pipeline_service.rb | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) (limited to 'app/services/ci/create_pipeline_service.rb') diff --git a/app/services/ci/create_pipeline_service.rb b/app/services/ci/create_pipeline_service.rb index 0386c1e8829..b22904fa4f1 100644 --- a/app/services/ci/create_pipeline_service.rb +++ b/app/services/ci/create_pipeline_service.rb @@ -20,25 +20,20 @@ module Ci protected: project.protected_for?(ref) ) - @pipeline.tap do |pipeline| - command = OpenStruct.new(ignore_skip_ci: ignore_skip_ci, - save_incompleted: save_on_errors, - trigger_request: trigger_request, - schedule: schedule, - seeds_block: block, - project: project, - current_user: current_user) - - sequence = SEQUENCE.map { |chain| chain.new(pipeline, command) } - - sequence_complete = sequence.none? do |chain| - chain.perform! - chain.break? - end + command = OpenStruct.new(ignore_skip_ci: ignore_skip_ci, + save_incompleted: save_on_errors, + seeds_block: block, + project: project, + current_user: current_user) + + + sequence = Gitlab::Ci::Pipeline::Chain::Sequence + .new(pipeline, command, SEQUENCE) + sequence.build! do |pipeline, sequence| update_merge_requests_head_pipeline if pipeline.persisted? - if sequence_complete + if sequence.complete? cancel_pending_pipelines if project.auto_cancel_pending_pipelines? pipeline_created_counter.increment(source: source) @@ -49,6 +44,9 @@ module Ci private + def process_pipeline_sequence + end + def commit @commit ||= project.commit(origin_sha || origin_ref) end -- cgit v1.2.1