Reputation: 1538
Background: We'd like to lock branch for merging while deploy Jenkins job is running
Question:
Is there way to programmatically lock GitLab branch?
e.g. To set "maintainers_can_push": false" on GitLab protected branch
Checked so far:
Upvotes: 1
Views: 1156
Reputation: 94676
At https://docs.gitlab.com/ee/api/branches.html#protect-repository-branch there is a link to the page https://docs.gitlab.com/ee/api/protected_branches.html devoted to API calls for listing protected branches, protect and unprotect them.
To protect a branch call POST /projects/:id/protected_branches
. For example
curl --request POST --header "PRIVATE-TOKEN: <your_access_token>" 'https://gitlab.example.com/api/v4/projects/5/protected_branches?name=*-stable&push_access_level=30&merge_access_level=30&unprotect_access_level=40'
Upvotes: 1