Commit 7aa26dee authored by Kamil Trzciński's avatar Kamil Trzciński

Merge branch 'create-merge-pipelines-ce' into 'master'

Backport: Use merge request MERGE ref for attached merge request pipelines

See merge request gitlab-org/gitlab-ce!26702
parents 2bd2fc20 57f11456
...@@ -55,15 +55,7 @@ module MergeRequests ...@@ -55,15 +55,7 @@ module MergeRequests
end end
def create_pipeline_for(merge_request, user) def create_pipeline_for(merge_request, user)
return unless Feature.enabled?(:ci_merge_request_pipeline, return unless can_create_pipeline_for?(merge_request)
merge_request.source_project,
default_enabled: true)
##
# UpdateMergeRequestsWorker could be retried by an exception.
# MR pipelines should not be recreated in such case.
return if merge_request.merge_request_pipeline_exists?
return if merge_request.has_no_commits?
create_detached_merge_request_pipeline(merge_request, user) create_detached_merge_request_pipeline(merge_request, user)
end end
...@@ -80,6 +72,16 @@ module MergeRequests ...@@ -80,6 +72,16 @@ module MergeRequests
end end
end end
def can_create_pipeline_for?(merge_request)
##
# UpdateMergeRequestsWorker could be retried by an exception.
# pipelines for merge request should not be recreated in such case.
return false if merge_request.merge_request_pipeline_exists?
return false if merge_request.has_no_commits?
true
end
def can_use_merge_request_ref?(merge_request) def can_use_merge_request_ref?(merge_request)
Feature.enabled?(:ci_use_merge_request_ref, project, default_enabled: true) && Feature.enabled?(:ci_use_merge_request_ref, project, default_enabled: true) &&
!merge_request.for_fork? !merge_request.for_fork?
......
...@@ -263,19 +263,6 @@ describe MergeRequests::CreateService do ...@@ -263,19 +263,6 @@ describe MergeRequests::CreateService do
expect(merge_request.actual_head_pipeline).to be_merge_request_event expect(merge_request.actual_head_pipeline).to be_merge_request_event
end end
end end
context "when the 'ci_merge_request_pipeline' feature flag is disabled" do
before do
stub_feature_flags(ci_merge_request_pipeline: false)
end
it 'does not create a detached merge request pipeline' do
expect(merge_request).to be_persisted
merge_request.reload
expect(merge_request.merge_request_pipelines.count).to eq(0)
end
end
end end
context "when .gitlab-ci.yml does not have merge_requests keywords" do context "when .gitlab-ci.yml does not have merge_requests keywords" do
......
...@@ -230,17 +230,6 @@ describe MergeRequests::RefreshService do ...@@ -230,17 +230,6 @@ describe MergeRequests::RefreshService do
end.not_to change { @merge_request.merge_request_pipelines.count } end.not_to change { @merge_request.merge_request_pipelines.count }
end end
end end
context "when the 'ci_merge_request_pipeline' feature flag is disabled" do
before do
stub_feature_flags(ci_merge_request_pipeline: false)
end
it 'does not create a detached merge request pipeline' do
expect { subject }
.not_to change { @merge_request.merge_request_pipelines.count }
end
end
end end
context "when .gitlab-ci.yml does not have merge_requests keywords" do context "when .gitlab-ci.yml does not have merge_requests keywords" do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment