Allow "pipeline must succeed" to merge if the pipeline was empty
Release notes
Previously when no pipeline manifests because of the nature of your changes, you would be prevented from merging those changes if you had Pipelines must succeed
setting enabled. Now, an exemption for that setting exists so that when your CI configurations evaluate to an empty pipeline you can still merge your changes.
Problem to solve
A merge request cannot be merged under the following conditions:
-
Pipeline must succeed
is enable in project settings - Changes in the MR are such that CI config evaluates to all jobs being skipped, so no pipeline manifests. For example, using
job:rules
orworkflow:rules
- Absence of a pipeline fails the condition that "pipeline must succeed" to allow merge according to the project settings
Proposal
NOTE: This proposal depends on a new preparing
state to be added to MergeRequest#merge_status
state machine in issue !54900 (merged).
- Introduce a project setting
require_pipeline_presence
(defaulttrue
) - Allow the project setting to be changed via API
- We might need to ensure that a MR is in
preparing
state any time a merge request pipeline is being created. - Change
MergeRequest#mergeable_ci_state?
to take in consideration the project setting.
diff --git a/app/models/merge_request.rb b/app/models/merge_request.rb
index 5fad876d3fb..005940d0894 100644
--- a/app/models/merge_request.rb
+++ b/app/models/merge_request.rb
@@ -1296,7 +1296,9 @@ def can_be_merged_via_command_line_by?(user)
end
def mergeable_ci_state?
+ return false if preparing?
return true unless project.only_allow_merge_if_pipeline_succeeds?
+ return true unless project.require_pipeline_presence?
return false unless actual_head_pipeline
return true if project.allow_merge_on_skipped_pipeline? && actual_head_pipeline.skipped?
The UI components will be completed in issue #300471.
Intended users
- Delaney (Development Team Lead)
- Sasha (Software Developer)
- Devon (DevOps Engineer)
- Rachel (Release Manager)
User experience goal
Further details
Permissions and Security
Permissions required to perform the described:
- Project Owner
- Project Maintainer
Documentation
Availability & Testing
- Unit tests is required for the new project setting
require_pipeline_presence
implementations - Integration test (feature test) is required to ensure:
- Merge request cannot be merged when
require_pipeline_presence
is true and the pipeline is skipped - Merge request can be merged when
require_pipeline_presence
is true and the pipeline presence but is empty - Merge request can be merged when
require_pipeline_presence
is true and the pipeline succeeds - Merge request can be merged when
require_pipeline_presence
is false and the pipeline is skipped
- Merge request cannot be merged when
- End-to-end test not required.