查询代码库保护分支列表。
调试
您可以在OpenAPI Explorer中直接运行该接口,免去您计算签名的困扰。运行成功后,OpenAPI Explorer可以自动生成SDK代码示例。
调试
授权信息
请求语法
GET /repository/{repositoryId}/protect_branches HTTP/1.1
路径参数
|
名称 |
类型 |
必填 |
描述 |
示例值 |
| repositoryId |
integer |
是 |
代码库 ID |
2813489 |
请求参数
|
名称 |
类型 |
必填 |
描述 |
示例值 |
| organizationId |
string |
是 |
企业标识,也称企业 id,字符串形式,可在云效访问链接中获取,如 https://devops.aliyun.com/organization/【OrganizationId】 |
60de7a6852743a5162b5f957 |
| accessToken |
string |
否 |
个人访问令牌。 使用阿里云 AK+SK 或使用 STS 临时授权方式不需要传该字段 |
f0b1e61db5961df5975a93f9129d2513 |
返回参数
|
名称 |
类型 |
描述 |
示例值 |
|
object |
Schema of Response |
||
| requestId |
string |
请求 ID |
313A1BF6-63B7-52D4-A098-952221A65254 |
| errorMessage |
string |
错误信息 |
"" |
| errorCode |
string |
错误码 |
SYSTEM_UNKNOWN_ERROR |
| success |
boolean |
调用是否成功 |
true |
| result |
array<object> |
返回结果列表 |
|
|
array<object> |
返回结果 |
||
| id |
integer |
保护分支规则 ID |
19285 |
| branch |
string |
保护分支名称 |
protectedBranch |
| createdAt |
string |
创建时间,格式为 YYYY-MM-DD HH:mm:ss。 |
2022-03-18 14:24:54 |
| updatedAt |
string |
更新时间,格式为 YYYY-MM-DD HH:mm:ss。 |
2022-03-18 14:24:54 |
| allowPushRoles |
array |
允许推送角色列表 |
|
|
integer |
角色 40:管理员 30:开发者 |
[40, 30] |
|
| allowPushUserIds |
array |
允许推送用户 ID |
|
|
integer |
Codeup 的用户 I'D |
19238 |
|
| allowPushUsers |
array<object> |
允许推送的用户列表 |
|
|
object |
用户信息 |
||
| id |
integer |
Codeup 的用户 ID |
19238 |
| name |
string |
用户名称 |
阿里云云效 |
| username |
string |
用户昵称 |
codeup-test |
|
string |
用户邮箱 |
username@example.com |
|
| avatar |
string |
头像地址 |
https://tcs-devops.aliyuncs.com/thumbnail/112afcb7a6a35c3f67f1bea827c4/w/100/h/100 |
| allowMergeRoles |
array |
允许合并角色列表 |
|
|
integer |
40:管理者 |
[40, 30] |
|
| allowMergeUserIds |
array |
允许合并用户 ID |
|
|
integer |
Codeup 的用户 ID |
19238 |
|
| allowMergeUsers |
array<object> |
允许合并的用户信息列表 |
|
|
object |
用户信息 |
||
| id |
integer |
Codeup 的用户 ID |
19238 |
| name |
string |
用户名称 |
阿里云云效 |
| username |
string |
用户昵称 |
codeup-test |
|
string |
用户邮箱 |
username@example.com |
|
| avatar |
string |
头像地址 |
https://tcs-devops.aliyuncs.com/thumbnail/112afcb7a6a35c3f67f1bea827c4/w/100/h/100 |
| mergeRequestSetting |
object |
合并前的代码评审设置 |
|
| isRequired |
boolean |
是否开启 |
true |
| mrMode |
string |
评审模式 |
general |
| isAllowSelfApproval |
boolean |
是否允许创建者通过代码评审 |
true |
| isRequireDiscussionProcessed |
boolean |
是否要求评审全部已解决 |
true |
| isResetApprovalWhenNewPush |
boolean |
是否在有新的提交时重置评审 |
false |
| minimumApproval |
integer |
评审通过的最少人数 注:仅普通模式生效 |
1 |
| allowMergeRequestRoles |
array |
允许合并请求的角色列表 |
|
|
integer |
40:管理员(默认) |
[40, 30] |
|
| defaultAssignees |
array<object> |
默认评审人 |
|
|
object |
评审人信息 |
||
| id |
integer |
Codeup 的用户 ID |
19238 |
| username |
string |
用户昵称 |
codeup-test |
| name |
string |
用户名称 |
阿里云云效 |
|
string |
用户邮箱 |
username@example.com |
|
| avatar |
string |
头像地址 |
https://tcs-devops.aliyuncs.com/thumbnail/112afcb7a6a35c3f67f1bea827c4/w/100/h/100 |
| whiteList |
string |
评审文件白名单 注意:加入白名单的文件不受「评审通过的最少人数」限制,无需强制人工评审 |
**.java |
| testSettingDTO |
object |
合并前的自动化状态检查设置 |
|
| isRequired |
boolean |
是否开启 |
false |
| codeGuidelinesDetection |
object |
代码规约扫描 |
|
| enabled |
boolean |
是否开启 |
false |
| message |
string |
描述信息 |
test_code_guide_lines |
| sensitiveInfoDetection |
object |
敏感信息扫描 |
|
| enabled |
boolean |
是否开启 |
false |
| message |
string |
描述信息 |
test_code_sensitive_info |
| checkTaskQualityConfig |
object |
代码质量检测 |
|
| enabled |
boolean |
是否开启 |
false |
| bizNo |
string |
任务流水号 |
123456 |
| taskName |
string |
任务名称 |
biz-task-quality |
| message |
string |
描述信息 |
test_task_quality |
| checkConfig |
object |
MR 卡点流水线配置 |
|
| checkItems |
array<object> |
配置项 |
|
|
object |
配置项 |
||
| name |
string |
流水线名称 |
测试流水线 |
| isRequired |
boolean |
是否卡点 |
false |
| matches |
array |
保护分支匹配列表 |
|
|
string |
匹配的分支名称 |
["pb"] |
示例
正常返回示例
JSON格式
{
"requestId": "313A1BF6-63B7-52D4-A098-952221A65254",
"errorMessage": "\"\"",
"errorCode": "SYSTEM_UNKNOWN_ERROR",
"success": true,
"result": [
{
"id": 19285,
"branch": "protectedBranch",
"createdAt": "2022-03-18 14:24:54",
"updatedAt": "2022-03-18 14:24:54",
"allowPushRoles": [
0
],
"allowPushUserIds": [
19238
],
"allowPushUsers": [
{
"id": 19238,
"name": "阿里云云效",
"username": "codeup-test",
"email": "username@example.com",
"avatar": "https://tcs-devops.aliyuncs.com/thumbnail/112afcb7a6a35c3f67f1bea827c4/w/100/h/100"
}
],
"allowMergeRoles": [
0
],
"allowMergeUserIds": [
19238
],
"allowMergeUsers": [
{
"id": 19238,
"name": "阿里云云效",
"username": "codeup-test",
"email": "username@example.com",
"avatar": "https://tcs-devops.aliyuncs.com/thumbnail/112afcb7a6a35c3f67f1bea827c4/w/100/h/100"
}
],
"mergeRequestSetting": {
"isRequired": true,
"mrMode": "general",
"isAllowSelfApproval": true,
"isRequireDiscussionProcessed": true,
"isResetApprovalWhenNewPush": false,
"minimumApproval": 1,
"allowMergeRequestRoles": [
0
],
"defaultAssignees": [
{
"id": 19238,
"username": "codeup-test",
"name": "阿里云云效",
"email": "username@example.com",
"avatar": "https://tcs-devops.aliyuncs.com/thumbnail/112afcb7a6a35c3f67f1bea827c4/w/100/h/100"
}
],
"whiteList": "**.java"
},
"testSettingDTO": {
"isRequired": false,
"codeGuidelinesDetection": {
"enabled": false,
"message": "test_code_guide_lines"
},
"sensitiveInfoDetection": {
"enabled": false,
"message": "test_code_sensitive_info"
},
"checkTaskQualityConfig": {
"enabled": false,
"bizNo": "123456",
"taskName": "biz-task-quality",
"message": "test_task_quality"
},
"checkConfig": {
"checkItems": [
{
"name": "测试流水线",
"isRequired": false
}
]
}
},
"matches": [
"[\"pb\"]"
]
}
]
}
错误码
|
HTTP status code |
错误码 |
错误信息 |
描述 |
|---|---|---|---|
| 403 | Forbidden.AccessDenied | The user is not authorized to perform the operation. | 用户无权限执行相关操作 |
| 403 | Forbidden.UserNotInCurrentOrganization | The user is not in the organization and is not authorized to perform the operation. | 当前用户不在该企业中,无权进行操作。 |
访问错误中心查看更多错误码。
变更历史
更多信息,参考变更详情。