-
|
I would like to automatically create a merge request approval rule. project.approvalrules.create(
{
"name": rule_name,
"approvals_required": 1,
"rule_type": "regular",
"branches": ["main"], # This does not have an effect.
"group_ids": approver_group_ids,
})
Any idea how to fix this? |
Beta Was this translation helpful? Give feedback.
-
|
I'm not sure if this is even supported by the GitLab API: https://archives.docs.gitlab.com/17.11/api/merge_request_approvals/#create-project-approval-rule |
Beta Was this translation helpful? Give feedback.
-
|
I found a solution project = gl.projects.get("my-project")
main_branch = project.protectedbranches.get("main")
project.approvalrules.create(
{
"name": rule_name,
"approvals_required": 1,
"rule_type": "regular",
"protected_branch_ids": [main_branch_id.id],
"group_ids": approver_group_ids,
}
)
|
Beta Was this translation helpful? Give feedback.
I found a solution