Skip to content

[FEAT] Add controls for GitLab merge request project settings #498

Description

@Karine-Bauch

Is your feature request related to a problem? Please describe.

Suggestion from @p1-dta

Plumber currently analyzes CI/CD configuration and several GitLab project settings, but it does not provide controls for the configuration available under:

Settings > Merge requests

These settings define how merge requests can be merged and can have an important impact on repository consistency, CI enforcement, review workflow, and Git history.

In organizations managing many GitLab projects, these settings are often expected to follow a common policy.

However, projects can currently drift from these expected settings without being detected by Plumber.

The main settings that should be covered are:

  • Merge method
  • Merge options
  • Squash commits when merging
  • Merge checks

Describe the solution you'd like

Add dedicated GitLab controls for the main Merge Request project settings.

Each control should compare the current GitLab project configuration with the expected configuration defined in .plumber.yaml.


1. Merge method

Suggested control:

projectMergeMethodMustMatchPolicy

GitLab allows exactly one merge method to be selected:

  • merge — Merge commit
  • rebase_merge — Merge commit with semi-linear history
  • ff — Fast-forward merge

The Plumber configuration should therefore define a single expected value rather than a list of allowed values.

Example:

gitlab:
  controls:
    projectMergeMethodMustMatchPolicy:
      enabled: true
      method: ff

A finding should be emitted when the configured GitLab merge method does not match the expected method.

For example:

Expected:
  merge_method: ff

Actual:
  merge_method: merge

Automatic rebase (only since GitLab 19.4)

For the following merge methods:

  • rebase_merge
  • ff

GitLab also provides:

Enable automatic rebase prior to merge

This setting should be handled by the same control because it is directly associated with the selected merge method.

Example:

gitlab:
  controls:
    projectMergeMethodMustMatchPolicy:
      enabled: true
      method: rebase_merge
      automaticRebase: true

or:

gitlab:
  controls:
    projectMergeMethodMustMatchPolicy:
      enabled: true
      method: ff
      automaticRebase: false

automaticRebase should only be evaluated when the selected merge method supports it.

For:

method: merge

the automaticRebase setting should either be ignored or rejected during configuration validation.


2. Merge options

Suggested control:

projectMergeOptionsMustMatchPolicy

GitLab currently exposes several independent options in the Merge options section.

The initial control should support the following three settings:

  • Automatically resolve merge request diff threads when they become outdated
  • Show link to create or view a merge request when pushing from the command line
  • Enable "Delete source branch" option by default

Example configuration:

gitlab:
  controls:
    projectMergeOptionsMustMatchPolicy:
      enabled: true
      automaticallyResolveOutdatedDiffThreads: true
      showMergeRequestLinkOnPush: true
      deleteSourceBranchByDefault: true

Each option should be evaluated independently.

Only properties explicitly defined in .plumber.yaml should be checked.

For example:

projectMergeOptionsMustMatchPolicy:
  enabled: true
  deleteSourceBranchByDefault: true

would only enforce the Delete source branch default and would not impose any policy on the two other options.

A separate finding should preferably be emitted for each mismatch.

Example:

Merge option does not match policy

Setting:
  deleteSourceBranchByDefault

Expected:
  true

Actual:
  false

3. Squash commits when merging

Suggested control:

projectSquashOptionMustMatchPolicy

GitLab exposes a dedicated policy for squashing commits when merging.

The control should ensure that the project's squash policy matches the configured expected value.

Example:

gitlab:
  controls:
    projectSquashOptionMustMatchPolicy:
      enabled: true
      option: always

Possible GitLab values include:

never
default_off
default_on
always

The configuration should expect a single value because a GitLab project can only have one squash policy configured at a time.

Example finding:

Expected:
  squash_option: always

Actual:
  squash_option: default_on

4. Merge checks

Suggested control:

projectMergeChecksMustMatchPolicy

The control should verify the independent settings available in the Merge checks section.

For example:

  • Pipelines must succeed
  • All threads must be resolved
  • Skipped pipelines are considered successful

Example:

gitlab:
  controls:
    projectMergeChecksMustMatchPolicy:
      enabled: true
      pipelinesMustSucceed: true
      allThreadsMustBeResolved: true
      skippedPipelinesAreSuccessful: false

As with Merge options, only explicitly configured values should be checked.

For example:

projectMergeChecksMustMatchPolicy:
  enabled: true
  pipelinesMustSucceed: true

would only verify that successful pipelines are required before merge.

Each non-compliant setting should produce its own finding.


Example complete configuration

gitlab:
  controls:

    projectMergeMethodMustMatchPolicy:
      enabled: true
      method: ff
      automaticRebase: true

    projectMergeOptionsMustMatchPolicy:
      enabled: true
      automaticallyResolveOutdatedDiffThreads: true
      showMergeRequestLinkOnPush: true
      deleteSourceBranchByDefault: true

    projectSquashOptionMustMatchPolicy:
      enabled: true
      option: always

    projectMergeChecksMustMatchPolicy:
      enabled: true
      pipelinesMustSucceed: true
      allThreadsMustBeResolved: true
      skippedPipelinesAreSuccessful: false

This would allow an organization to define a complete Merge Request policy and detect projects whose GitLab configuration has drifted from it.

Implementation hints

All the proposed settings are exposed by the GitLab Projects API and can be retrieved from the project configuration.

Relevant fields are:

merge_method
automatic_rebase_enabled  # Available for Ultimate only and appeared in GitLab 19.4
resolve_outdated_diff_discussions
printing_merge_request_link_enabled
remove_source_branch_after_merge
squash_option  # Available for Ultimate/Premium only
only_allow_merge_if_pipeline_succeeds
only_allow_merge_if_all_discussions_are_resolved
allow_merge_on_skipped_pipeline

They map to the proposed controls as follows:

Merge method
├── merge_method
└── automatic_rebase_enabled

Merge options
├── resolve_outdated_diff_discussions
├── printing_merge_request_link_enabled
└── remove_source_branch_after_merge

Squash commits when merging
└── squash_option

Merge checks
├── only_allow_merge_if_pipeline_succeeds
├── only_allow_merge_if_all_discussions_are_resolved
└── allow_merge_on_skipped_pipeline

For controls containing multiple boolean settings, each mismatch should generate a separate finding.

This makes the result easier to understand and allows each configuration issue to be reported independently.

Why It's Valuable

Merge Request settings are part of a project's development and governance policy.

Adding these controls would allow Plumber to:

  • Detect configuration drift across GitLab projects.
  • Enforce a consistent merge strategy.
  • Enforce automatic rebasing when required.
  • Standardize source branch cleanup.
  • Standardize Merge Request workflow options.
  • Enforce squash policies.
  • Ensure CI pipelines cannot be bypassed before merge.
  • Ensure review discussions are resolved when required.
  • Audit GitLab project settings alongside CI/CD configuration.
  • Help organizations enforce repository governance consistently across many projects.

This would extend Plumber's GitLab project-level controls beyond CI configuration and provide better coverage of Merge Request governance.

Activity

  1. p1-dta commented on Sep 28, 2026

    @p1-dta
    Contributor

    Thanks @Karine-Bauch for translating my thoughts into a great issue, great job.

    I have a few feedback still:

    About 4. Merge checks:

    • "Skipped pipelines are considered successful" depends on "Pipelines must succeed", and should be check only if the dependancy is enabled.
    • "Status checks must succeed" is missing.

    IMHO, there is also a missing control: projectMergeRequestApprovals, where we should be able to define the default "Minimum required approvals" value (0 by gitlab default), and any additional rule.

    For example, I need to check that I have a rule names "Maintainer", the target branch (empty means all), a defined list of users and a define list of groups, and how many approvol are needed for this one.

    We also need to control the following MR approval settings:

    Approval settings controls

    • (bool) Prevent approval by merge request creator
    • (bool) Prevent approvals by users who add commits
    • (bool) Prevent editing approval rules in merge requests
    • (bool) Require user re-authentication (password or SAML) to approve
    • (select one) When a commit is added:
      • Keep approvals
      • Remove all approvals
      • Remove approvals by Code Owners if their files changed
  2. p1-dta commented on Sep 28, 2026

    @p1-dta
    Contributor

    And yes, this might be a meta issue that should be split into many smaller ones ^^ sorry about that !

  3. Karine-Bauch commented on Sep 29, 2026

    @Karine-Bauch
    Author

    Thanks @Karine-Bauch for translating my thoughts into a great issue, great job.

    I have a few feedback still:

    About 4. Merge checks:

    [...]

    Thanks for your help and for adding settings I don't have accès (I'm not on premium or ultimate plan).

  4. p1-dta commented on Sep 29, 2026

    @p1-dta
    Contributor

    @Karine-Bauch there is already many of those controls implemented in the CLI :

    plumber/.plumber.yaml

    Lines 222 to 228 in 4a1e7a3

    mergeRequestApprovalSettingsMustBeCompliant:
    enabled: true
    preventApprovalByAuthor: true
    preventApprovalsByCommitters: true
    preventEditingApprovalRulesInMR: true
    requireReAuthToApprove: false
    behaviorWhenCommitIsAdded: remove_all_approvals

  5. p1-dta commented on Sep 29, 2026

    @p1-dta
    Contributor

    Same for other controls:

    plumber/.plumber.yaml

    Lines 238 to 247 in 4a1e7a3

    mergeRequestSettingsMustBeCompliant:
    enabled: false
    mergeMethod: ff # linear history, no merge commits
    squashOption: default_on # squash to one commit by default
    mergePipelinesEnabled: true # run the pipeline on the merged result
    mergeTrainsEnabled: false
    allowMergeOnSkippedPipeline: false # never merge when CI was skipped
    resolveOutdatedDiffDiscussions: true # auto-resolve stale review threads
    printingMergeRequestLinkEnabled: true
    removeSourceBranchAfterMerge: true # clean up the branch after merge

  6. Karine-Bauch commented on Oct 1, 2026

    @Karine-Bauch
    Author

    @p1-dta Could you check which controls are needed on premium/ultimate plans ?

    I'll check for the free plan.

  7. p1-dta commented on Oct 12, 2026

    @p1-dta
    Contributor

    @Karine-Bauch I can't say which one is which, I have everything enabled, I can't tell which one come from premium or ultimate

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions