获取项目MR列表 - ListProjectMergeRequests
功能介绍
获取项目MR列表
授权信息
账号根用户具备所有API的调用权限,如果使用账号下的IAM用户调用当前API,该IAM用户需具备如下身份策略权限,更多的权限说明请参见权限和授权项。
授权项 | 访问级别 | 资源类型(*为必须) | 条件键 | 别名 | 依赖的授权项 |
|---|---|---|---|---|---|
codeartsrepo:repository:getMergeRequest | Read | - | - | - | - |
URI
GET /v4/projects/{project_id}/merge-requests
参数 | 是否必选 | 参数类型 | 描述 |
|---|---|---|---|
project_id | 是 | String | 参数解释: 项目的32位uuid,项目唯一标识,通过查询项目列表接口查询项目列表获取。 取值范围: 字符串长度32。 |
参数 | 是否必选 | 参数类型 | 描述 |
|---|---|---|---|
offset | 否 | Integer | 参数解释: 偏移量,从0开始。 取值范围: 0~2147483647 默认取值: 0 |
limit | 否 | Integer | 参数解释: 返回数量。 取值范围: 1~100 默认取值: 20 |
state | 否 | String | 参数解释: 返回指定状态的合并请求。 约束限制: 默认取值: all |
order_by | 否 | String | 参数解释: 排序方式。 取值范围: 默认取值: created_at |
sort | 否 | String | 参数解释: 排序方式。 约束限制: 默认取值: desc |
author_id | 否 | String | 参数解释: 返回由指定ID用户创建的合并请求。 多个ID以逗号','分隔,返回满足条件的合并请求并集。 |
source_branch | 否 | String | 参数解释: 返回指定源分支的合并请求。 |
target_branch | 否 | String | 参数解释: 返回指定目标分支的合并请求。 |
search | 否 | String | 参数解释: 合并请求关键字搜索。 返回标题或者描述包含对应关键字的合并请求。 |
source_repository_id | 否 | Integer | 参数解释: 查询指定源仓库的数据。 |
only_count | 否 | Boolean | 参数解释: 是否仅返回合并请求计数。 取值范围: 默认取值: false |
labels | 否 | String | 参数解释: 查询包含指定labels的合并请求。 取值范围: 1~2000 |
topic | 否 | String | 参数解释: 合并请求主题 |
请求参数
参数 | 是否必选 | 参数类型 | 描述 |
|---|---|---|---|
X-Auth-Token | 是 | String | 参数解释: 用户Token。 通过调用IAM服务获取用户Token接口获取(响应消息头中X-Subject-Token的值)。 约束限制: 不涉及。 取值范围: 字符串长度不少于1,不超过10万。 默认取值: 不涉及。 |
响应参数
状态码:200
参数 | 参数类型 | 描述 |
|---|---|---|
X-Total | String | 参数解释: 项目MR列表的总数 |
参数 | 参数类型 | 描述 |
|---|---|---|
[数组元素] | Array of MergeRequestListBasicDto objects | 合并请求基本信息 |
参数 | 参数类型 | 描述 |
|---|---|---|
id | Integer | 参数解释: 合并请求ID。 |
iid | Integer | 参数解释: 合并请求位于当前仓库序号。 |
title | String | 参数解释: 合并请求标题。 |
source_branch | String | 参数解释: 合并请求源分支。 |
target_branch | String | 参数解释: 合并请求目标分支。 |
state | String | 参数解释: 合并请求状态。 |
created_at | String | 参数解释: 合并请求创建时间。 |
updated_at | String | 参数解释: 合并请求更新时间。 |
source_repository_id | Integer | 参数解释: 合并请求源仓库ID。 |
review_mode | String | 参数解释: 合并请求检视模式。 |
author | UserBasicDto object | 参数解释: 合并请求作者。 |
closed_at | String | 参数解释: 合并请求关闭时间。 |
closed_by | UserBasicDto object | 参数解释: 合并请求关闭人。 |
merged_at | String | 参数解释: 合并请求合并时间。 |
merged_by | UserBasicDto object | 参数解释: 合并请求合并人。 |
pipeline_status | String | 参数解释: 合并请求流水线状态。 |
codequality_status | String | 参数解释: 合并请求代码质量状态。 |
pipeline_status_with_code_quality | String | 参数解释: 合并请求流水线状态。 |
notes | Integer | 参数解释: 合并请求检视意见。 |
source_repository | ProjectSimpleDto object | 参数解释: 合并请求源仓库信息。 |
target_repository | ProjectSimpleDto object | 参数解释: 合并请求目标仓库信息。 |
web_url | String | 参数解释: 合并请求URL地址。 |
added_lines | Integer | 参数解释: 合并请求新增代码行数。 |
removed_lines | Integer | 参数解释: 合并请求删除代码行数。 |
merge_request_type | String | 参数解释: 合并请求检视模式。 |
source_git_url | String | 参数解释: 合并请求git地址。 |
labels | Array of Map<String,Object> objects | 参数解释: 合并请求标签。 |
score | Integer | 参数解释: 合并请求分数。 |
min_merged_score | Integer | 参数解释: 合并请求最小合入分数。 |
source_product_id | String | 参数解释: 合并请求源项目ID。 |
target_product_id | String | 参数解释: 合并请求目标项目ID。 |
product_name | String | 参数解释: 合并请求项目名。 |
notes_count | NotesCountDto object | 参数解释: 合并请求检视意见计数。 |
moderation_result | Boolean | 参数解释: 合并请求审核结果。 |
moderation_time | Long | 参数解释: 合并请求审核时间。 |
moderation_status | Integer | 参数解释: 合并请求审核状态。 |
参数 | 参数类型 | 描述 |
|---|---|---|
id | Integer | 参数解释: 用户id。 取值范围: 1~2147483647 |
name | String | 参数解释: 用户名称。 |
username | String | 参数解释: 用户名。 |
state | String | 参数解释: 用户状态。 取值范围: |
service_license_status | Integer | 服务级权限状态 0:停用 1:启用 |
avatar_url | String | 用户头像url |
avatar_path | String | 用户头像路径 |
String | 用户邮箱 | |
name_cn | String | 用户中文名称 |
web_url | String | 用户个人首页 |
nick_name | String | 用户昵称 |
tenant_name | String | 租户名称 |
error_message | String | 参数解释: 部分查询接口校验到传参里的用户权限不足或不存在时,返回该用户但该字段不为空用于提示。 |
参数 | 参数类型 | 描述 |
|---|---|---|
id | Integer | 仓库id |
description | String | 仓库描述信息 |
name | String | 仓库名称 |
name_with_namespace | String | 组织名/组织名.../仓库名 |
path | String | 仓库路径 |
path_with_namespace | String | 仓库完整路径 |
created_at | String | 创建时间 |
updated_at | String | 更新时间 |
archived | Boolean | 是否归档 |
is_kia | Boolean | 是否机密 |
ssh_url_to_repo | String | 仓库ssh地址 |
http_url_to_repo | String | 仓库http地址 |
web_url | String | 仓库页面链接 |
readme_url | String | 仓库readme文件链接 |
project_id | String | 项目id |
project_name | String | 项目名称 |
develop_mode | String | 仓库开发模式:normal、CR |
moderation_result | Boolean | 审核状态 |
参数 | 参数类型 | 描述 |
|---|---|---|
notes_count | Integer | 检视意见总数 |
unresolved_notes_count | Integer | 未解决的检视意见数量 |
already_resolved_count | Integer | 已解决的检视意见数量 |
need_resolved_count | Integer | 需要解决的检视意见总数 |
状态码:401
参数 | 参数类型 | 描述 |
|---|---|---|
error_code | String | 参数解释: 错误码。 |
error_msg | String | 参数解释: 错误信息。 |
状态码:404
参数 | 参数类型 | 描述 |
|---|---|---|
error_code | String | 参数解释: 错误码。 |
error_msg | String | 参数解释: 错误信息。 |
请求示例
无
响应示例
状态码:200
成功
{
"id" : 72674,
"iid" : 7,
"title" : "新建文件",
"source_branch" : "ddd1",
"target_branch" : "master",
"state" : "opened",
"created_at" : "2025-05-21T12:03:32.000+08:00",
"updated_at" : "2025-06-17T15:30:02.000+08:00",
"source_repository_id" : 2111983939,
"review_mode" : "approval",
"author" : {
"id" : 9124,
"name" : "test",
"username" : "c369c68f1ff84679b5a8ed904d8bff1c",
"state" : "active",
"service_license_status" : null,
"name_cn" : "test",
"nick_name" : "beta_dv",
"tenant_name" : "example_name",
"error_message" : null
},
"closed_at" : "2025-05-21T12:03:32.000+08:00",
"closed_by" : null,
"merged_at" : null,
"merged_by" : null,
"pipeline_status" : "",
"codequality_status" : null,
"pipeline_status_with_code_quality" : "",
"notes" : 0,
"web_url" : "https://example.com/********/2111983939/7/mergedetail?source=ddd1&target=master",
"added_lines" : 0,
"removed_lines" : 0,
"merge_request_type" : "MergeRequest",
"source_git_url" : "git@example.com:3e1f6634946144c2b1ccb46fb8152b8f/dddd.git",
"labels" : [ {
"color" : "#000",
"name" : "Bug",
"description" : "456",
"id" : 8,
"title" : "Bug",
"type" : null,
"textColor" : "#FFFFFF"
}, {
"color" : "#000",
"name" : "bug",
"description" : "456",
"id" : 7,
"title" : "bug",
"type" : null,
"textColor" : "#FFFFFF"
} ],
"score" : 0,
"min_merged_score" : null,
"source_project_id" : "3e1f6634946144c2b1ccb46fb8152b8f",
"target_project_id" : null,
"product_name" : null,
"notes_count" : null,
"moderation_result" : null,
"moderation_time" : null,
"moderation_status" : null,
"source_repository" : {
"id" : 2111983939,
"description" : "ddd",
"name" : "dddd",
"name_with_namespace" : "3e1f6634946144c2b1ccb46fb8152b8f/dddd",
"path" : "dddd",
"path_with_namespace" : "3e1f6634946144c2b1ccb46fb8152b8f/dddd",
"created_at" : "2024-11-30T17:46:46.000+08:00",
"updated_at" : "2024-11-30T17:46:46.000+08:00",
"archived" : false,
"ssh_url_to_repo" : "git@example.com:3e1f6634946144c2b1ccb46fb8152b8f/dddd.git",
"http_url_to_repo" : "https://example.com/3e1f6634946144c2b1ccb46fb8152b8f/dddd.git",
"project_id" : null,
"project_name" : null,
"develop_mode" : null,
"moderation_result" : null
},
"target_repository" : {
"id" : 2111983939,
"description" : "ddd",
"name" : "dddd",
"name_with_namespace" : "3e1f6634946144c2b1ccb46fb8152b8f/dddd",
"path" : "dddd",
"path_with_namespace" : "3e1f6634946144c2b1ccb46fb8152b8f/dddd",
"created_at" : "2024-11-30T17:46:46.000+08:00",
"updated_at" : "2024-11-30T17:46:46.000+08:00",
"archived" : false,
"ssh_url_to_repo" : "git@example.com:3e1f6634946144c2b1ccb46fb8152b8f/dddd.git",
"http_url_to_repo" : "https://example.com/3e1f6634946144c2b1ccb46fb8152b8f/dddd.git",
"project_id" : null,
"project_name" : null,
"develop_mode" : null,
"moderation_result" : null
}
} 状态码:401
未认证
{
"error_code" : "CH.00000002",
"error_msg" : "认证信息无法识别"
} 状态码:404
不存在
{
"error_code" : "CH.00402000",
"error_msg" : "该仓库不存在,请检查后重试。"
} 状态码
状态码 | 描述 |
|---|---|
200 | 成功 |
401 | 未认证 |
404 | 不存在 |
错误码
请参见错误码。

