Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'app/services/ci/create_pipeline_service.rb')
-rw-r--r--app/services/ci/create_pipeline_service.rb53
1 files changed, 13 insertions, 40 deletions
diff --git a/app/services/ci/create_pipeline_service.rb b/app/services/ci/create_pipeline_service.rb
index 2d7f5014aa9..70ad18e80eb 100644
--- a/app/services/ci/create_pipeline_service.rb
+++ b/app/services/ci/create_pipeline_service.rb
@@ -19,9 +19,13 @@ module Ci
Gitlab::Ci::Pipeline::Chain::Limit::Size,
Gitlab::Ci::Pipeline::Chain::Validate::External,
Gitlab::Ci::Pipeline::Chain::Populate,
+ Gitlab::Ci::Pipeline::Chain::StopDryRun,
Gitlab::Ci::Pipeline::Chain::Create,
Gitlab::Ci::Pipeline::Chain::Limit::Activity,
- Gitlab::Ci::Pipeline::Chain::Limit::JobActivity].freeze
+ Gitlab::Ci::Pipeline::Chain::Limit::JobActivity,
+ Gitlab::Ci::Pipeline::Chain::CancelPendingPipelines,
+ Gitlab::Ci::Pipeline::Chain::Metrics,
+ Gitlab::Ci::Pipeline::Chain::Pipeline::Process].freeze
# Create a new pipeline in the specified project.
#
@@ -68,21 +72,14 @@ module Ci
bridge: bridge,
**extra_options(options))
- sequence = Gitlab::Ci::Pipeline::Chain::Sequence
- .new(pipeline, command, SEQUENCE)
+ # Ensure we never persist the pipeline when dry_run: true
+ @pipeline.readonly! if command.dry_run?
- sequence.build! do |pipeline, sequence|
- schedule_head_pipeline_update
+ Gitlab::Ci::Pipeline::Chain::Sequence
+ .new(pipeline, command, SEQUENCE)
+ .build!
- if sequence.complete?
- cancel_pending_pipelines if project.auto_cancel_pending_pipelines?
- pipeline_created_counter.increment(source: source)
-
- Ci::ProcessPipelineService
- .new(pipeline)
- .execute(nil, initial_process: true)
- end
- end
+ schedule_head_pipeline_update if pipeline.persisted?
# If pipeline is not persisted, try to recover IID
pipeline.reset_project_iid unless pipeline.persisted? ||
@@ -110,38 +107,14 @@ module Ci
commit.try(:id)
end
- def cancel_pending_pipelines
- Gitlab::OptimisticLocking.retry_lock(auto_cancelable_pipelines) do |cancelables|
- cancelables.find_each do |cancelable|
- cancelable.auto_cancel_running(pipeline)
- end
- end
- end
-
- # rubocop: disable CodeReuse/ActiveRecord
- def auto_cancelable_pipelines
- project.ci_pipelines
- .where(ref: pipeline.ref)
- .where.not(id: pipeline.same_family_pipeline_ids)
- .where.not(sha: project.commit(pipeline.ref).try(:id))
- .alive_or_scheduled
- .with_only_interruptible_builds
- end
- # rubocop: enable CodeReuse/ActiveRecord
-
- def pipeline_created_counter
- @pipeline_created_counter ||= Gitlab::Metrics
- .counter(:pipelines_created_total, "Counter of pipelines created")
- end
-
def schedule_head_pipeline_update
pipeline.all_merge_requests.opened.each do |merge_request|
UpdateHeadPipelineForMergeRequestWorker.perform_async(merge_request.id)
end
end
- def extra_options(content: nil)
- { content: content }
+ def extra_options(content: nil, dry_run: false)
+ { content: content, dry_run: dry_run }
end
end
end