Help us learn about your current experience with the documentation. Take the survey.
组安全设置 API
- Tier: Ultimate
- Offering: GitLab.com, GitLab Self-Managed, GitLab Dedicated
所有对组安全设置的 API 调用都必须进行身份验证。
如果用户不是私有组的成员,对该私有组的请求将返回 404 Not Found 状态码。
更新 secret_push_protection_enabled 设置
将组中所有项目的 secret_push_protection_enabled 设置更新为提供的值。
设置为 true 可为组中的所有项目启用密钥推送保护。
前提条件:
- 您必须至少拥有该组的 Maintainer 角色。
| 属性 | 类型 | 必需 | 描述 |
|---|---|---|---|
id |
integer 或 string | 是 | 已认证用户所属的组的 ID 或URL 编码路径 |
secret_push_protection_enabled |
boolean | 是 | 是否为组启用密钥推送保护。 |
projects_to_exclude |
整数数组 | 否 | 要从该功能中排除的项目 ID。 |
curl --request PUT \
--header "PRIVATE-TOKEN: <your_access_token>" \
--url "https://gitlab.example.com/api/v4/groups/7/security_settings?secret_push_protection_enabled=true&projects_to_exclude[]=1&projects_to_exclude[]=2"示例响应:
{
"secret_push_protection_enabled": true,
"errors": []
}