Merge request approvals settings

Merge request approvals can be defined at the project level or at the merge request level.



List project-level MR approval rules:

p_mras = project.approvalrules.list()

Change project-level MR approval rule:

p_approvalrule.user_ids = [234]

Delete project-level MR approval rule:


Get project-level or MR-level MR approvals settings:

p_mras = project.approvals.get()

mr_mras = mr.approvals.get()

Get MR-level approval state:

mr_approval_state = mr.approval_state.get()

Change project-level or MR-level MR approvals settings:

p_mras.approvals_before_merge = 2

mr_mras.set_approvers(approvals_required = 1)

Change project-level MR allowed approvers:

                                 approver_group_ids=[653, 654])

Create a new MR-level approval rule or change an existing MR-level approval rule:

mr.approvals.set_approvers(approvals_required = 1, approver_ids=[105],
                            approver_group_ids=[653, 654],
                            approval_rule_name="my MR custom approval rule")

List MR-level MR approval rules:


Change MR-level MR approval rule:

mr_approvalrule.user_ids = [105]
mr_approvalrule.approvals_required = 2
mr_approvalrule.group_ids = [653, 654]

Create a MR-level MR approval rule:

    "name": "my MR custom approval rule",
    "approvals_required": 2,
    "rule_type": "regular",
    "user_ids": [105],
    "group_ids": [653, 654],