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/workers/ci/external_pull_requests/create_pipeline_worker.rb')
-rw-r--r--app/workers/ci/external_pull_requests/create_pipeline_worker.rb40
1 files changed, 40 insertions, 0 deletions
diff --git a/app/workers/ci/external_pull_requests/create_pipeline_worker.rb b/app/workers/ci/external_pull_requests/create_pipeline_worker.rb
new file mode 100644
index 00000000000..211ea1f2990
--- /dev/null
+++ b/app/workers/ci/external_pull_requests/create_pipeline_worker.rb
@@ -0,0 +1,40 @@
+# frozen_string_literal: true
+
+module Ci
+ module ExternalPullRequests
+ class CreatePipelineWorker # rubocop:disable Scalability/IdempotentWorker
+ include ApplicationWorker
+
+ data_consistency :always
+ queue_namespace :pipeline_creation
+ feature_category :pipeline_authoring
+ urgency :high
+ worker_resource_boundary :cpu
+
+ def perform(project_id, user_id, external_pull_request_id)
+ user = User.find_by_id(user_id)
+ return unless user
+
+ project = Project.find_by_id(project_id)
+ return unless project
+
+ external_pull_request = project.external_pull_requests.find_by_id(external_pull_request_id)
+ return unless external_pull_request
+
+ ::Ci::CreatePipelineService
+ .new(project, user, execute_params(external_pull_request))
+ .execute(:external_pull_request_event, external_pull_request: external_pull_request)
+ end
+
+ private
+
+ def execute_params(pull_request)
+ {
+ ref: pull_request.source_ref,
+ source_sha: pull_request.source_sha,
+ target_sha: pull_request.target_sha
+ }
+ end
+ end
+ end
+end