发布链接 API

极狐GitLab CI/CD 作业令牌认证的支持引入于 15.1 版本。

本 API 用来操作极狐GitLab 发布 的链接。

极狐GitLab 支持 httphttps 以及 ftp 资源的链接。

列出发布链接

Release Links 中的 external 字段废弃于 15.9 且移除于 16.0。

从发布中获取资产链接。

GET /projects/:id/releases/:tag_name/assets/links
参数 类型 是否必需 描述
id integer/string yes ID 或者 项目 URL 路径
tag_name string yes 发布关联的标签。

请求示例:

curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/24/releases/v0.1/assets/links"

响应示例:

[
  {
    "id":2,
    "name":"awesome-v0.2.msi",
    "url":"http://192.168.10.15:3000/msi",
    "link_type":"other"
  },
  {
    "id":1,
    "name":"awesome-v0.2.dmg",
    "url":"http://192.168.10.15:3000",
    "link_type":"other"
  }
]

获取发布链接

Release Links 中的 external 字段废弃于 15.9 且移除于 16.0。

从发布中获取资产链接。

GET /projects/:id/releases/:tag_name/assets/links/:link_id
参数 类型 是否必需 描述
id integer/string yes ID 或者 项目 URL 路径
tag_name string yes 发布关联的标签。
link_id integer yes 链接的 ID。

请求示例:

curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/24/releases/v0.1/assets/links/1"

响应示例:

{
  "id":1,
  "name":"awesome-v0.2.dmg",
  "url":"http://192.168.10.15:3000",
  "link_type":"other"
}

创建发布链接

Release Links 中的 external 字段废弃于 15.9 且移除于 16.0。

为发布创建一个链接。

POST /projects/:id/releases/:tag_name/assets/links
参数 类型 是否必需 描述
id integer/string yes ID 或者项目 URL 路径
tag_name string yes 发布关联的标签。
name string yes 链接的名称。在发布中必须唯一。
url string yes 链接的 URL。在发布中必须唯一。
filepath string no 已废弃:使用 direct_asset_path 代替。
direct_asset_path string no Direct Asset 链接的可选路径。
link_type string no 链接类型:otherrunbookimagepackage,默认为 other

请求示例:

curl --request POST \
    --header "PRIVATE-TOKEN: <your_access_token>" \
    --data name="hellodarwin-amd64" \
    --data url="https://gitlab.example.com/mynamespace/hello/-/jobs/688/artifacts/raw/bin/hello-darwin-amd64" \
    --data direct_asset_path="/bin/hellodarwin-amd64" \
    "https://gitlab.example.com/api/v4/projects/20/releases/v1.7.0/assets/links"

响应示例:

{
  "id":2,
  "name":"hellodarwin-amd64",
  "url":"https://gitlab.example.com/mynamespace/hello/-/jobs/688/artifacts/raw/bin/hello-darwin-amd64",
  "direct_asset_url":"https://gitlab.example.com/mynamespace/hello/-/releases/v1.7.0/downloads/bin/hellodarwin-amd64",
  "external":false, // deprecated in GitLab 15.9, will be removed in GitLab 16.0.
  "link_type":"other"
}

更新发布链接

Release Links 中的 external 字段废弃于 15.9 且移除于 16.0。

更新发布的链接。

PUT /projects/:id/releases/:tag_name/assets/links/:link_id
参数 类型 是否必需 描述
id integer/string yes ID 或者项目 URL 路径
tag_name string yes 发布关联的标签。
link_id integer yes 链接 ID。
name string no 链接名称。
url string no 链接 URL。
filepath string no 已废弃,使用 direct_asset_path 代替。
direct_asset_path string no Direct Asset 链接的可选路径。
link_type string no 链接类型: otherrunbookimagepackage,默认为 other
notenameurl至少指定一个。

请求示例:

curl --request PUT --data name="new name" --data link_type="runbook" \
     --header "PRIVATE-TOKEN: <your_access_token>" \
     "https://gitlab.example.com/api/v4/projects/24/releases/v0.1/assets/links/1"

响应示例:

{
  "id":1,
  "name":"new name",
  "url":"http://192.168.10.15:3000",
  "link_type":"runbook"
}

删除发布链接

Release Links 中的 external 字段废弃于 15.9 且移除于 16.0。

删除发布的链接。

DELETE /projects/:id/releases/:tag_name/assets/links/:link_id
参数 类型 是否必需 描述
id integer/string yes ID 或者项目 URL 路径
tag_name string yes 发布关联的标签。
link_id integer yes 链接 ID。

请求示例:

curl --request DELETE --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/24/releases/v0.1/assets/links/1"

响应示例:

{
  "id":1,
  "name":"new name",
  "url":"http://192.168.10.15:3000",
  "link_type":"other"
}