Skip to content

how can I specify the branches for a merge request approval rule? #3225

Answered by guerda
guerda asked this question in Q&A
Discussion options

You must be logged in to vote

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,
                }
            )

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by guerda
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant