创建合并请求。
接口说明
该接口需要确保当前企业已经在使用新版 MR,具体可看当前企业的合并请求页面是否已是新版本。
调试
您可以在OpenAPI Explorer中直接运行该接口,免去您计算签名的困扰。运行成功后,OpenAPI Explorer可以自动生成SDK代码示例。
调试
授权信息
请求语法
POST /api/v4/projects/{repositoryId}/merge_requests HTTP/1.1
路径参数
|
名称 |
类型 |
必填 |
描述 |
示例值 |
| repositoryId |
integer |
是 |
代码库 ID |
2369234 |
请求参数
|
名称 |
类型 |
必填 |
描述 |
示例值 |
| organizationId |
string |
是 |
企业标识,也称企业 id,字符串形式,可在云效访问链接中获取,如 https://devops.aliyun.com/organization/【OrganizationId】 |
6270e731cfea268afc21ccac |
| accessToken |
string |
否 |
个人访问令牌。 使用阿里云 AK+SK 或使用 STS 临时授权方式不需要传该字段 |
f0b1e61db5961df5975a93f9129d2513 |
| body |
object |
是 |
请求 Body |
|
| sourceProjectId |
integer |
是 |
源代码库 ID |
2369234 |
| sourceBranch |
string |
是 |
源分支名称 |
sourceBranch |
| targetProjectId |
integer |
是 |
目标代码库 ID |
2369234 |
| targetBranch |
string |
是 |
目标分支名称 |
targetBranch |
| title |
string |
是 |
合并请求标题 |
测试合并请求的标题 |
| createFrom |
string |
是 |
创建来源,固定取值为:WEB |
WEB |
| description |
string |
否 |
合并请求描述信息 |
测试合并请求 |
| reviewerIds |
array |
否 |
评审人阿里云账号 ID 列表 |
|
|
string |
否 |
阿里云账号 ID |
1234567890 |
|
| workItemIds |
string |
否 |
关联工作项 ID,支持多个,以逗号隔开 |
722200214032b6b31e6f1434ab |
返回参数
|
名称 |
类型 |
描述 |
示例值 |
|
object |
Schema of Response |
||
| requestId |
string |
请求 ID |
F7B85D1B-D1C2-140F-A039-341859F130B9 |
| errorMessage |
string |
错误信息 |
"" |
| errorCode |
string |
错误码 |
SYSTEM_UNKNOWN_ERROR |
| success |
boolean |
调用是否成功 |
true |
| result |
object |
返回结果 |
|
| mrBizId |
string |
合并请求唯一 ID |
bca90244c4b749e0b109df52ac0eb570 |
| projectId |
integer |
代码库 ID |
2369234 |
| localId |
integer |
合并请求局部 ID,表示代码库下的第几个合并请求 |
1 |
| createTime |
string |
创建时间 |
2023-06-02T03:41:22Z |
| updateTime |
string |
更新时间 |
2023-06-02T03:41:22Z |
| mrType |
string |
合并请求类型,固定为:CODE_REVIEW |
CODE_REVIEW |
| sourceProjectId |
integer |
评审分支所在的代码库 ID |
2369234 |
| sourceBranch |
string |
源分支名称 |
sourceBranch |
| targetProjectId |
integer |
目标分支所在的代码库 ID |
2369234 |
| targetBranch |
string |
目标分支名称 |
targetBranch |
| title |
string |
合并请求标题 |
测试合并请求的标题 |
| description |
string |
合并请求描述信息 |
测试合并请求 |
| reviewers |
array<object> |
评审人信息列表 |
|
|
object |
评审人信息 |
||
| id |
integer |
Codeup 用户 ID |
7905 |
| name |
string |
用户名称 |
codeup |
| username |
string |
企业登录名 |
root-codeup |
| state |
string |
用户状态,可选值:
|
active |
| avatarUrl |
string |
评审人的头像地址 |
https://tcs-devops.aliyuncs.com/thumbnail/112afcb7a6a35c3f67f1bea827c4/w/100/h/100 |
|
string |
邮箱地址 |
username@example.com |
|
| hasReviewed |
boolean |
评审人是否已经评审过 |
false |
| reviewOpinionStatus |
string |
评审意见
|
PASS |
| author |
object |
创建人信息 |
|
| id |
integer |
Codeup 的用户 ID |
19230 |
| name |
string |
用户名称 |
test-codeup |
| username |
string |
用户登录名 |
test-codeup-nickname |
| state |
string |
用户状态,可选值:
|
active |
| avatarUrl |
string |
头像地址 |
https://tcs-devops.aliyuncs.com/thumbnail/112afcb7a6a35c3f67f1bea827c4/w/100/h/100 |
|
string |
用户邮箱 |
username@example.com |
|
| subscribers |
array<object> |
订阅人信息列表 |
|
|
object |
订阅人信息 |
||
| id |
integer |
Codeup 用户 ID |
10092 |
| name |
string |
用户名称 |
test-codeup |
| username |
string |
用户登录名 |
root-test-codeup |
| state |
string |
用户状态,可选值:
|
active |
| avatarUrl |
string |
头像地址 |
https://tcs-devops.aliyuncs.com/thumbnail/112afcb7a6a35c3f67f1bea827c4/w/100/h/100 |
|
string |
用户邮箱 |
username@example.com |
|
| status |
string |
合并请求状态
|
UNDER_REVIEW |
| createFrom |
string |
创建来源,取值为:WEB |
WEB |
| ahead |
integer |
源分支相较于目标分支多出的 commit 数量 |
2 |
| behind |
integer |
目标分支相较于源分支落后的 commit 数量 |
0 |
| detailUrl |
string |
详情页地址 |
xxx |
| webUrl |
string |
合并请求的 web 地址 |
https://codeup.aliyun.com/xxx/test/test |
| allRequirementsPass |
boolean |
是否所有卡点通过 |
true |
| supportMergeFastForwardOnly |
boolean |
是否支持 fast-forward-only 的合并方式 |
true |
示例
正常返回示例
JSON格式
{
"requestId": "F7B85D1B-D1C2-140F-A039-341859F130B9",
"errorMessage": "\"\"",
"errorCode": "SYSTEM_UNKNOWN_ERROR",
"success": true,
"result": {
"mrBizId": "bca90244c4b749e0b109df52ac0eb570",
"projectId": 2369234,
"localId": 1,
"createTime": "2023-06-02T03:41:22Z",
"updateTime": "2023-06-02T03:41:22Z",
"mrType": "CODE_REVIEW",
"sourceProjectId": 2369234,
"sourceBranch": "sourceBranch",
"targetProjectId": 2369234,
"targetBranch": "targetBranch",
"title": "测试合并请求的标题",
"description": "测试合并请求",
"reviewers": [
{
"id": 7905,
"name": "codeup",
"username": "root-codeup",
"state": "active",
"avatarUrl": "https://tcs-devops.aliyuncs.com/thumbnail/112afcb7a6a35c3f67f1bea827c4/w/100/h/100",
"email": "username@example.com",
"hasReviewed": false,
"reviewOpinionStatus": "PASS"
}
],
"author": {
"id": 19230,
"name": "test-codeup",
"username": "test-codeup-nickname",
"state": "active",
"avatarUrl": "https://tcs-devops.aliyuncs.com/thumbnail/112afcb7a6a35c3f67f1bea827c4/w/100/h/100",
"email": "username@example.com"
},
"subscribers": [
{
"id": 10092,
"name": "test-codeup",
"username": "root-test-codeup",
"state": "active",
"avatarUrl": "https://tcs-devops.aliyuncs.com/thumbnail/112afcb7a6a35c3f67f1bea827c4/w/100/h/100",
"email": "username@example.com"
}
],
"status": "UNDER_REVIEW",
"createFrom": "WEB",
"ahead": 2,
"behind": 0,
"detailUrl": "xxx",
"webUrl": "https://codeup.aliyun.com/xxx/test/test\n",
"allRequirementsPass": true,
"supportMergeFastForwardOnly": true
}
}
错误码
访问错误中心查看更多错误码。
变更历史
更多信息,参考变更详情。