Updated on 2025-07-24 GMT+08:00

Configuring Project-Level Merge Request Rules

Constraints

Table 1 Constraints on setting merge request rules

Item

Description

Permission

Project manager or project administrator can set project-level webhooks. For details, see Configuring Project-Level Permissions.

Configuring Merge Request Rules

You can select Inherit from project. The settings in the project are automatically inherited and cannot be changed.

You can also access the target project homepage of the code to be configured and choose Settings > Policy Settings > Merge Requests. You can create a merge request rule by referring to the following steps:

  1. Select a merge mechanism. There are two MR mechanisms: score and approval. The differences between the two mechanisms are as follows:

    • Scoring mechanism: This mode includes only code review and is based on scoring (0—5). Code can be merged only when the score meets the gate conditions.
    • The approval method consists of code review and merge approval. Code can be merged only after the number of reviewers and approvers reaches gate requirements.

  2. After selecting a mechanism, set other parameters by referring to the following table. The configuration takes effect for the entire code repo.

    Table 2 Parameters for setting the merge condition, settings, and mode

    Parameter

    Description

    Example Value

    Merge Conditions

    Optional. There are two options:

    • Merge after all reviews are resolved. After this parameter is selected, if Must resolve is selected as the review comment, a message Review comment gate: failed is displayed and the Merge button is unavailable. If it is a common review comment, the Resolved button does not exist, the MR is not intercepted by the merge condition.
    • Must be associated with CodeArts Req The options are as follows:
      1. Associate only 1 ticket number. After this option is selected, one MR can be associated with only one ticket number.
      2. All E2E ticket numbers pass verification After this option is selected, all associated E2E ticket numbers must pass the verification.
      3. Branches to configure the MR policy: You can add multiple branches to configure the merge request policy. You can manually enter wildcard characters (for example, *-stable or production/*), and press Enter.
      CAUTION:

      The Use score as a merge gate parameter is available for the Pro edition.

    • Use score as a merge gate.

      By default, the project manager, repository owner, and project administrator can evaluate the MR. You can also add other roles. For permission configuration, see Configuring Project-Level Permissions. Selecting this option means that a committer, project manager, repository owner, or project administrator must evaluate the MR.

    *-stable indicates that the E2E trouble ticket number ending with -stable is matched.

    MR Settings

    Optional. Options:

    • Do not merge your own requests After this parameter is selected, the Merge button is unavailable when you view the MRs created by yourself. You need to ask the person who has the permission to merge the MRs.
    • Do not approve your own requests
    • Do not review your own requests
    • A repo administrator or project manager can force merge code
    • Allow code review and comment for merged or closed MRs
    • Mark the automatically merged MRs as Closed If all commits in MR A are included in MR A, MR B is automatically merged after MR A is merged. By default, the B MR is marked as merged. You can use this parameter to mark the B MR as closed.)
    • Cannot re-open a Closed MR This function is enabled by default. You can enable or disable it as required.
    • Enable "Delete source branch after merged" when creating MRs
    • Forbid squash merge (Forbid to select squash merge when creating a merge request)
    • Enable Squash merge for new MRs

    Merge Method

    Mandatory. The options are as follows:

    • Merge commit If this parameter is selected, a merge commit is created for every merge, and merging is allowed as long as there are no conflicts. That is, no matter whether the baseline node is the latest node, the baseline node can be merged if there is no conflict.
      • Do not generate Merge nodes during Squash merge: If this parameter is selected, no merge node is generated during the squash merging.
      • Use MR merger to generate Merge Commit: If this parameter is selected, the commit information is recorded.

        Use MR creator to generate Merge Commit: If this parameter is selected, the commit information is recorded.

    • Merge commit with semi-linear history. If this parameter is selected, a merge commit is recorded for each merge operation. However, different from Merge commit, the commitment must be performed based on the latest commit node of the target branch. Otherwise, the system prompts the developer to perform the rebase operation. In this merging mode, if the MR can be correctly constructed, the target branch can be correctly constructed after the merge is complete.
    • Fast-forward If this parameter is selected, no merge commits are created and all merges are fast-forwarded, which means that merging is only allowed if the branch could be fast-forwarded. When fast-forward merge is not possible, the user is given the option to rebase.

  3. After setting the parameters, click Submit to save the configurations.

If your merge mechanism is Approval and you want to set the merge policy for a specified branch or all branches in the repository, refer to this section.

Configuring Branch Policy

Go to the target repository homepage, choose Settings > Policy Settings > Merge Requests. In the Branch Policies area, click Create Branch Policy, and set parameters by referring to the following table.

Table 3 Parameters for creating a branch policy

Parameter

Description

Branch

Mandatory. Select a branch from the drop-down list. You can select all branches.

Reviewers Required

Mandatory. The default value is 0, indicating that the review gate can be passed without being reviewed by the reviewer.

Approvals Required

Mandatory. The default value is 0, indicating that the approval gate can be passed without being approved by the approver.

Reset approval gate

Optional. This option is selected by default, indicating that MR approval gate is reset when code is re-pushed to the source branch of the MR.

Reset review gate

Optional. This option is selected by default, indicating that the MR review gate is reset when code is re-pushed to the source branch of the MR.

Add approvers/reviewers only from the following ones

Optional. If this option is selected, you can configure the list of New Approvers and New Reviewers. If you want to add additional members, you can only add members from the lists.

Enable pipeline gate

Optional. If this option is selected, before the merge, you need to pass all pipeline gates. This rule integrates the CI into the code development process.

Mergers

Optional. The list of mandatory mergers can be configured. When a merge request is created, the list is automatically synchronized to the merge request.

Approvers

Optional. The list of mandatory approvers can be configured. When a merge request is created, the list is automatically synchronized to the merge request.

Reviewers

Optional. The list of mandatory reviewers can be configured. When a merge request is created, the list is automatically synchronized to the merge request.

Setting Branch Policies

  1. The following is an example of the branch policy priority:
    • If a branch has both policies A and B in a repository, the latest created branch policy is used by default.
    • There are policies A and B in the repository. Branch A and branch B are configured for policy A, and branch A is also configured for policy B. When a merge request whose target branch is Branch A is committed, the policy B is used by default.
  2. After the merger, approver, and reviewer are configured for a branch for the first time, the data is automatically loaded from the browser cache when a merge request is created. If the names of the merger, approver, and reviewer are changed and their repository permission is removed, a message is displayed on the page for creating a merge request, indicating the current username is inconsistent with that in the list of merger, approver, and reviewer. In this case, you only need to remove the user as prompted to update the cache data. The user will not be displayed in the subsequent merge request.