以编程方式锁定 GitLab 分支

programmatically lock GitLab branch

背景: 我们想在部署 Jenkins 作业 运行

时锁定分支以进行合并

问题: 有没有办法以编程方式锁定 GitLab 分支?
例如在 GitLab 保护分支

上设置 "maintainers_can_push": false"

目前已检查:

  1. GitLab 中未发现任何提及此类功能的信息 插入。
  2. GitLab branches API page
  3. 上未找到任何内容

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 致力于 API 呼吁列出受保护的分支,保护和取消保护它们。

保护分支调用POST /projects/:id/protected_branches。例如

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'