diff options
author | Shinya Maeda <shinya@gitlab.com> | 2018-11-02 14:21:14 +0300 |
---|---|---|
committer | Shinya Maeda <shinya@gitlab.com> | 2018-11-02 14:21:14 +0300 |
commit | 54824e5b8f36c2ab2c41511bdc5e363e4c771124 (patch) | |
tree | 1aef39487177c9c3d8d932343f2633acd3283184 /app | |
parent | 88224ccea67290e1bfa600379715ab278984ccdf (diff) |
Merge request pipelinemerge-request-pipeline
Diffstat (limited to 'app')
-rw-r--r-- | app/services/ci/create_merge_request_pipeline_service.rb | 30 | ||||
-rw-r--r-- | app/services/ci/create_pipeline_service.rb | 3 |
2 files changed, 32 insertions, 1 deletions
diff --git a/app/services/ci/create_merge_request_pipeline_service.rb b/app/services/ci/create_merge_request_pipeline_service.rb new file mode 100644 index 00000000000..e16382c36c0 --- /dev/null +++ b/app/services/ci/create_merge_request_pipeline_service.rb @@ -0,0 +1,30 @@ +# frozen_string_literal: true + +module Ci + class CreateMergeRequestPipelineService < BaseService + attr_reader :source_branch, :source_project + + def execute(pipeline) + return if pipeline.tag? + return unless pipeline.has_merge_request_option? + + @source_branch = pipeline.ref + @source_project = pipeline.project + + merge_requests.each do |merge_request| + Ci::CreatePipelineService + .new(merge_request.target_project, + pipeline.user, + ref: source_branch, + merge_request: merge_request) + .execute(pipeline.source) + end + end + + private + + def merge_requests + @merge_requests ||= MergeRequest.where(source_project: source_project, source_branch: source_branch) + end + end +end diff --git a/app/services/ci/create_pipeline_service.rb b/app/services/ci/create_pipeline_service.rb index 92a8438ab2f..81cbc8fa99f 100644 --- a/app/services/ci/create_pipeline_service.rb +++ b/app/services/ci/create_pipeline_service.rb @@ -12,7 +12,7 @@ module Ci Gitlab::Ci::Pipeline::Chain::Populate, Gitlab::Ci::Pipeline::Chain::Create].freeze - def execute(source, ignore_skip_ci: false, save_on_errors: true, trigger_request: nil, schedule: nil, &block) + def execute(source, ignore_skip_ci: false, save_on_errors: true, trigger_request: nil, schedule: nil, merge_request: nil, &block) @pipeline = Ci::Pipeline.new command = Gitlab::Ci::Pipeline::Chain::Command.new( @@ -23,6 +23,7 @@ module Ci before_sha: params[:before], trigger_request: trigger_request, schedule: schedule, + merge_request: merge_request, ignore_skip_ci: ignore_skip_ci, save_incompleted: save_on_errors, seeds_block: block, |