合并队列 API

  • 引入于极狐GitLab 12.9。
  • 通过使用此 API,您可以消耗合并队列条目。

每个用于合并队列的 API 调用都必须通过开发者或更高级别权限的授权。

如果用户不是项目成员并且项目是私有的,则对该项目的 GET 请求会返回 404 状态码。

如果项目无法使用合并队列,则返回 403 状态码。

合并队列 API 分页

默认情况下,GET 请求一次返回 20 个结果,因为 API 结果是分页的。

阅读更多关于分页的内容。

列出项目的合并队列

获取请求项目的所有合并队列:

GET /projects/:id/merge_trains
GET /projects/:id/merge_trains?scope=complete
参数 类型 是否必需 描述
id integer/string yes ID 或 URL 编码的项目路径
scope string no 按照给定范围,返回过滤的合并队列。可用范围为 active(待合并)和 complete(已合并)
sort string no 按照 ascdesc 的顺序返回合并队列。默认为 desc
curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/1/merge_trains"

响应示例:

[
  {
    "id": 110,
    "merge_request": {
      "id": 126,
      "iid": 59,
      "project_id": 20,
      "title": "Test MR 1580978354",
      "description": "",
      "state": "merged",
      "created_at": "2020-02-06T08:39:14.883Z",
      "updated_at": "2020-02-06T08:40:57.038Z",
      "web_url": "http://local.gitlab.test:8181/root/merge-train-race-condition/-/merge_requests/59"
    },
    "user": {
      "id": 1,
      "name": "Administrator",
      "username": "root",
      "state": "active",
      "avatar_url": "https://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon",
      "web_url": "http://local.gitlab.test:8181/root"
    },
    "pipeline": {
      "id": 246,
      "sha": "bcc17a8ffd51be1afe45605e714085df28b80b13",
      "ref": "refs/merge-requests/59/train",
      "status": "success",
      "created_at": "2020-02-06T08:40:42.410Z",
      "updated_at": "2020-02-06T08:40:46.912Z",
      "web_url": "http://local.gitlab.test:8181/root/merge-train-race-condition/pipelines/246"
    },
    "created_at": "2020-02-06T08:39:47.217Z",
    "updated_at": "2020-02-06T08:40:57.720Z",
    "target_branch": "feature-1580973432",
    "status": "merged",
    "merged_at": "2020-02-06T08:40:57.719Z",
    "duration": 70
  }
]