Protected tags API
- List protected tags
- Get a single protected tag or wildcard protected tag
- Protect repository tags
- Unprotect repository tags
Protected tags API
注意:此功能是在 GitLab 11.3 中引入的
有效的访问级别
当前,这些级别被认可:
0 => No access
30 => Developer access
40 => Maintainer access
List protected tags
从项目中获取受保护标签的列表. 此函数使用分页参数page
和per_page
来限制受保护标签的列表.
GET /projects/:id/protected_tags
Attribute | Type | Required | Description |
---|---|---|---|
id |
integer/string | yes | 经过身份验证的用户拥有的项目的 ID 或URL 编码路径 |
curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/5/protected_tags"
响应示例:
[ { "name": "release-1-0", "create_access_levels": [ { "access_level": 40, "access_level_description": "Maintainers" } ] }, ... ]
Get a single protected tag or wildcard protected tag
获取单个受保护标签或通配符受保护标签. 分页参数page
和per_page
可用于限制受保护标签的列表.
GET /projects/:id/protected_tags/:name
Attribute | Type | Required | Description |
---|---|---|---|
id |
integer/string | yes | 经过身份验证的用户拥有的项目的 ID 或URL 编码路径 |
name |
string | yes | 标签或通配符的名称 |
curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/5/protected_tags/release-1-0"
响应示例:
{ "name": "release-1-0", "create_access_levels": [ { "access_level": 40, "access_level_description": "Maintainers" } ] }
Protect repository tags
使用通配符保护的标签保护单个存储库标签或几个项目存储库标签.
POST /projects/:id/protected_tags
curl --request POST --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/5/protected_tags?name=*-stable&create_access_level=30"
Attribute | Type | Required | Description |
---|---|---|---|
id |
integer/string | yes | 经过身份验证的用户拥有的项目的 ID 或URL 编码路径 |
name |
string | yes | 标签或通配符的名称 |
create_access_level |
string | no | 允许创建的访问级别(默认值: 40 ,维护者访问级别) |
响应示例:
{ "name": "*-stable", "create_access_levels": [ { "access_level": 30, "access_level_description": "Developers + Maintainers" } ] }
Unprotect repository tags
取消保护给定的受保护标签或通配符受保护标签.
DELETE /projects/:id/protected_tags/:name
curl --request DELETE --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/5/protected_tags/*-stable"
Attribute | Type | Required | Description |
---|---|---|---|
id |
integer/string | yes | 经过身份验证的用户拥有的项目的 ID 或URL 编码路径 |
name |
string | yes | 标签名称 |