极狐GitLab 迁移 (批量导入) API

引入于极狐GitLab 14.1 版本。

使用极狐GitLab Migrations API,您可以查看使用极狐GitLab Group Migration 发起的迁移进度。

开始新的极狐GitLab 迁移

引入于极狐GitLab 14.2 版本。

POST /bulk_imports
参数 类型 是否必需 描述
configuration Hash yes 极狐GitLab 实例配置
configuration[url] String yes 极狐GitLab 实例网址
configuration[access_token] String yes 极狐GitLab 实例的访问令牌
entities Array yes 要导入的实体列表
entities[source_type] String yes 实体类型(仅 group_entity 支持)
entities[source_full_path] String yes 要导入的实体完整路径
entities[destination_name] String yes 实体目标 slug。已废弃,使用 destination_slug 代替
entities[destination_slug] String yes 实体目标 slug
entities[destination_namespace] String no 实体目标命名空间
curl --request POST --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/bulk_imports" \
  --data '{
    "configuration": {
      "url": "http://gitlab.example/",
      "access_token": "access_token"
    },
    "entities": [
      {
        "source_full_path": "source/full/path",
        "source_type": "group_entity",
        "destination_slug": "destination_slug",
        "destination_namespace": "destination/namespace/path"
      }
    ]
  }'
{ "id": 1, "status": "created", "source_type": "gitlab", "created_at": "2021-06-18T09:45:55.358Z", "updated_at": "2021-06-18T09:46:27.003Z" }

列出所有极狐GitLab 迁移

GET /bulk_imports
参数 类型 是否必需 描述
per_page integer no 每页要返回的记录数
page integer no 要检索的页面
sort string no 返回按创建日期升序 asc 或降序 desc 排列的极狐GitLab 迁移。默认为降序 desc
status string no 导入状态

状态可以是以下之一:

  • created
  • started
  • finished
  • failed
curl --request GET --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/bulk_imports?per_page=2&page=1"
[
    {
        "id": 1,
        "status": "finished",
        "source_type": "gitlab",
        "created_at": "2021-06-18T09:45:55.358Z",
        "updated_at": "2021-06-18T09:46:27.003Z"
    },
    {
        "id": 2,
        "status": "started",
        "source_type": "gitlab",
        "created_at": "2021-06-18T09:47:36.581Z",
        "updated_at": "2021-06-18T09:47:58.286Z"
    }
]

列出所有极狐GitLab 迁移的实体

GET /bulk_imports/entities
参数 类型 是否必需 描述
per_page integer no 每页要返回的记录数
page integer no 要检索的页面
sort string no 返回按创建日期升序 asc 或降序 desc 排列的极狐GitLab 迁移。默认为降序 desc
status string no 导入状态

状态可以是以下之一:

  • created
  • started
  • finished
  • failed
curl --request GET --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/bulk_imports/entities?per_page=2&page=1&status=started"
[
  {
    "id": 1,
    "bulk_import_id": 1,
    "status": "finished",
    "source_full_path": "source_group",
    "destination_slug": "destination_slug",
    "destination_namespace": "destination_path",
    "parent_id": null,
    "namespace_id": 1,
    "project_id": null,
    "created_at": "2021-06-18T09:47:37.390Z",
    "updated_at": "2021-06-18T09:47:51.867Z",
    "failures": []
  },
  {
    "id": 2,
    "bulk_import_id": 2,
    "status": "failed",
    "source_full_path": "another_group",
    "destination_slug": "another_slug",
    "destination_namespace": "another_namespace",
    "parent_id": null,
    "namespace_id": null,
    "project_id": null,
    "created_at": "2021-06-24T10:40:20.110Z",
    "updated_at": "2021-06-24T10:40:46.590Z",
    "failures": [
      {
        "relation": "group",
        "step": "extractor",
        "exception_message": "Error!",
        "exception_class": "Exception",
        "correlation_id_value": "dfcf583058ed4508e4c7c617bd7f0edd",
        "created_at": "2021-06-24T10:40:46.495Z",
        "pipeline_class": "BulkImports::Groups::Pipelines::GroupPipeline",
        "pipeline_step": "extractor"
      }
    ]
  }
]

获取极狐GitLab 迁移详细信息

GET /bulk_imports/:id
curl --request GET --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/bulk_imports/1"
{
  "id": 1,
  "status": "finished",
  "source_type": "gitlab",
  "created_at": "2021-06-18T09:45:55.358Z",
  "updated_at": "2021-06-18T09:46:27.003Z"
}

列出极狐GitLab 迁移实体

GET /bulk_imports/:id/entities
参数 类型 是否必需 描述
per_page integer no 每页要返回的记录数
page integer no 要检索的页面
sort string no 返回按创建日期升序 asc 或降序 desc 排列的极狐GitLab 迁移。默认为降序 desc
status string no 导入状态

状态可以是以下之一:

  • created
  • started
  • finished
  • failed
curl --request GET --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/bulk_imports/1/entities?per_page=2&page=1&status=finished"
[
    {
        "id": 1,
        "status": "finished",
        "source_type": "gitlab",
        "created_at": "2021-06-18T09:45:55.358Z",
        "updated_at": "2021-06-18T09:46:27.003Z"
    }
]

获取极狐GitLab 迁移实体详细信息

GET /bulk_imports/:id/entities/:entity_id
curl --request GET --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/bulk_imports/1/entities/2"
{
  "id": 1,
  "status": "finished",
  "source_type": "gitlab",
  "created_at": "2021-06-18T09:45:55.358Z",
  "updated_at": "2021-06-18T09:46:27.003Z"
}