Skip to content

Add feature flag allowing auto merge for incomplete pipelines

What does this MR do and why?

This adds a feature flag expanding the availability of "when pipeline succeeds"-type auto merges.

With this change, when the flag auto_merge_when_incomplete_pipeline_succeeds is enabled, auto merges will also become available for pipelines in the following states:

  • created: Users expect "when pipeline succeeds" action to be the default auto merge strategy as soon as they see the new pipeline. Users can see a pipeline as soon as it exists, even before it starts processing, and excluding created has caused unexpected immediate merges.
  • manual, scheduled: Both of these imply a type of delayed execution that is intentional, but could still benefit from increased merge automation (not having to wait for the action to be completed).

See:

MR acceptance checklist

Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Screenshots or screen recordings

Before After
Screenshot_2024-04-04_at_14-36-46_Update_.gitlab-ci.yml___125____Merge_requests___Administrator___Test___GitLab Screenshot_2024-04-04_at_14-35-26_Update_.gitlab-ci.yml___125____Merge_requests___Administrator___Test___GitLab

How to set up and validate locally

  1. Enable the flag auto_merge_when_incomplete_pipeline_succeeds:
    Feature.enable(:auto_merge_when_incomplete_pipeline_succeeds)
  2. In a project, create a merge request changing the .gitlab-ci.yml to
    workflow:
      rules:
        - if: $CI_MERGE_REQUEST_IID
        - if: $CI_COMMIT_TAG
        - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
    
    test:
      script: echo hi
      when: manual
      allow_failure: false
  3. Observe that the merge action is an auto-merge instead of an immediate merge.
  4. Set the MR to auto merge
  5. Run the pipeline
  6. Observe that it merges
Edited by Hordur Freyr Yngvason

Merge request reports