Skip to content

GitLab Next

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
GitLab
GitLab
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 36,888
    • Issues 36,888
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
    • Iterations
  • Merge requests 1,541
    • Merge requests 1,541
  • Requirements
    • Requirements
    • List
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
    • Test Cases
  • Operations
    • Operations
    • Metrics
    • Incidents
    • Environments
  • Packages & Registries
    • Packages & Registries
    • Container Registry
  • Analytics
    • Analytics
    • CI/CD
    • Code Review
    • Insights
    • Issue
    • Repository
    • Value Stream
  • Snippets
    • Snippets
  • Members
    • Members
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • GitLab.org
  • GitLabGitLab
  • Issues
  • #321267

Closed
Open
Created Feb 11, 2021 by Thao Yeager@thaoyeagerDeveloper

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.

https://docs.gitlab.com/ee/user/project/merge_requests/merge_when_pipeline_succeeds.html#only-allow-merge-requests-to-be-merged-if-the-pipeline-succeeds

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 or workflow: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 (default true)
  • 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
  • End-to-end test not required.

What does success look like, and how can we measure that?

What is the type of buyer?

Is this a cross-stage feature?

Edited Apr 09, 2021 by Thao Yeager
Assignee
Assign to
13.11
Milestone
13.11
Assign milestone
Time tracking
None
Due date
None