更新时间:2025-07-15 GMT+08:00
分享

获取仓库MR列表

功能介绍

获取仓库MR列表

调试

您可以在API Explorer中调试该接口,支持自动认证鉴权。API Explorer可以自动生成SDK代码示例,并提供SDK代码示例调试功能。

URI

GET /v4/repositories/{repository_id}/merge-requests

表1 路径参数

参数

是否必选

参数类型

描述

repository_id

Integer

参数解释:

仓库的ID,通过查询用户所有仓库接口查询项目列表获取。

约束限制:

不涉及。

取值范围:

1-2147483647

表2 Query参数

参数

是否必选

参数类型

描述

offset

Integer

参数解释:

偏移量,从0开始。

取值范围:

0-2147483647

默认取值:

0

limit

Integer

参数解释:

返回数量。

取值范围:

1-100

默认取值:

20

state

String

参数解释:

返回指定状态的合并请求。

约束限制:

  • all,表示所有状态。

  • opened,表示开启中状态

  • closed,表示已关闭状态

  • merged,表示已合并状态

默认取值:

all

枚举值:

  • all

  • opened

  • closed

  • merged

order_by

String

参数解释:

排序方式。

取值范围:

  • created_at,创建时间。

  • updated_at,更新时间。

默认取值:

created_at

枚举值:

  • created_at

  • updated_at

sort

String

参数解释:

排序方式。

约束限制:

  • asc,升序。

  • desc,降序。

默认取值:

desc

枚举值:

  • asc

  • desc

author_id

String

参数解释:

返回由指定ID用户创建的合并请求。

多个ID以逗号','分隔,返回满足条件的合并请求并集。

source_branch

String

参数解释:

返回指定源分支的合并请求。

target_branch

String

参数解释:

返回指定目标分支的合并请求。

search

String

参数解释:

合并请求关键字搜索。

返回标题或者描述包含对应关键字的合并请求。

source_repository_id

Integer

参数解释:

查询指定源仓库的数据。

only_count

Boolean

参数解释:

是否仅返回合并请求计数。

取值范围:

  • true,仅返回合并请求计数。

  • false,返回合并请求详细信息。

默认取值:

false

labels

String

参数解释:

查询包含指定labels的合并请求。

取值范围:

1-2000

请求参数

表3 请求Header参数

参数

是否必选

参数类型

描述

X-Auth-Token

String

参数解释:

用户Token。 通过调用IAM服务获取用户Token接口获取(响应消息头中X-Subject-Token的值)。

约束限制:

必传。

取值范围:

字符串长度不少于1,不超过10万。

默认取值:

不涉及。

响应参数

状态码:200

表4 响应Body参数

参数

参数类型

描述

[数组元素]

Array of MergeRequestListBasicDto objects

合并请求基本信息

表5 MergeRequestListBasicDto

参数

参数类型

描述

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

参数解释:

合并请求审核状态。

表6 UserBasicDto

参数

参数类型

描述

id

Integer

参数解释:

用户id。

取值范围:

1-2147483647

name

String

参数解释:

用户名称。

username

String

参数解释:

用户名。

state

String

用户状态

service_license_status

Integer

服务级权限状态 0:停用 1:启用

avatar_url

String

用户头像url

avatar_path

String

用户头像路径

email

String

用户邮箱

name_cn

String

用户中文名称

web_url

String

用户个人首页

nick_name

String

用户昵称

tenant_name

String

租户名称

error_message

String

参数解释:

部分查询接口校验到传参里的用户权限不足或不存在时,返回该用户但该字段不为空用于提示。

表7 ProjectSimpleDto

参数

参数类型

描述

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

审核状态

表8 NotesCountDto

参数

参数类型

描述

notes_count

Integer

检视意见总数

unresolved_notes_count

Integer

未解决的检视意见数量

already_resolved_count

Integer

已解决的检视意见数量

need_resolved_count

Integer

需要解决的检视意见总数

状态码:401

表9 响应Body参数

参数

参数类型

描述

error_code

String

参数解释:

错误码。

error_msg

String

参数解释:

错误信息。

状态码:404

表10 响应Body参数

参数

参数类型

描述

error_code

String

参数解释:

错误码。

error_msg

String

参数解释:

错误信息。

请求示例

响应示例

状态码:200

OK

{
  "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

Unauthorized

{
  "error_code" : "CH.00000002",
  "error_msg" : "认证信息无法识别"
}

状态码:404

Not Found

{
  "error_code" : "CH.00402000",
  "error_msg" : "该仓库不存在,请检查后重试。"
}

状态码

状态码

描述

200

OK

401

Unauthorized

404

Not Found

错误码

请参见错误码

相关文档