Tags API

Tags API

从项目中获取存储库标签的列表,按名称以相反的字母顺序排序. 如果可公开访问该存储库,则无需身份验证即可访问此端点.

Parameters:

在 GitLab 11.8 中引入了对search支持.

Get a single repository tag

获取由其名称确定的特定存储库标签. 如果可公开访问该存储库,则无需身份验证即可访问此端点.

  1. GET /projects/:id/repository/tags/:tag_name

Parameters:

Attribute Type Required Description
id integer/string yes 经过身份验证的用户拥有的项目的 ID 或
tag_name string yes 标签名称
  1. curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/5/repository/tags/v1.0.0"

示例响应:

  1. { "name": "v5.0.0", "message": null, "target": "60a8ff033665e1207714d6670fcd7b65304ec02f", "commit": { "id": "60a8ff033665e1207714d6670fcd7b65304ec02f", "short_id": "60a8ff03", "title": "Initial commit", "created_at": "2017-07-26T11:08:53.000+02:00", "parent_ids": [ "f61c062ff8bcbdb00e0a1b3317a91aed6ceee06b" ], "message": "v5.0.0\n", "author_name": "Arthur Verschaeve", "author_email": "contact@arthurverschaeve.be", "authored_date": "2015-02-01T21:56:31.000+01:00", "committer_name": "Arthur Verschaeve", "committer_email": "contact@arthurverschaeve.be", "committed_date": "2015-02-01T21:56:31.000+01:00" }, "release": null, "protected": false }

Parameters:

  • id (必填)-经过身份验证的用户拥有的项目的 ID 或
  • tag_name (必需)-标签的名称
  • ref (必需)-使用提交 SHA,另一个标签名称或分支名称创建标签.
  • message (可选)-创建带注释的标签.
  • release_description (可选)-将发行说明添加到 Git 标签并将其存储在 GitLab 数据库中.
  1. curl --request POST --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/5/repository/tags?tag_name=test&ref=master"

响应示例:

  1. { "commit": { "id": "2695effb5807a22ff3d138d593fd856244e155e7", "short_id": "2695effb", "title": "Initial commit", "created_at": "2017-07-26T11:08:53.000+02:00", "parent_ids": [ "2a4b78934375d7f53875269ffd4f45fd83a84ebe" ], "message": "Initial commit", "author_name": "John Smith", "author_email": "john@example.com", "authored_date": "2012-05-28T04:42:42-07:00", "committer_name": "Jack Smith", "committer_email": "jack@example.com", "committed_date": "2012-05-28T04:42:42-07:00" }, "release": { "tag_name": "1.0.0", "description": "Amazing release. Wow" }, "name": "v1.0.0", "target": "2695effb5807a22ff3d138d593fd856244e155e7", "message": null, "protected": false }

创建轻量级标签时,该消息将为null ,否则将包含注释.

在创建带注释的标签时,目标将包含标签对象 ID,否则在创建轻量级标签时将包含提交 ID.

如果出现错误,则返回带有解释性错误消息的状态代码 .

Delete a tag

删除具有给定名称的存储库的标记.

  1. DELETE /projects/:id/repository/tags/:tag_name
  • tag_name (必需)-标签的名称

将发行说明添加到现有的 Git 标签. 如果给定标签已经存在发行版,则返回状态码409 .

  1. POST /projects/:id/repository/tags/:tag_name/release

Parameters:

  • id (必填)-经过身份验证的用户拥有的 ID 或URL 编码路径
  • tag_name (必需)-标签的名称

要求正文:

  • description (必需)-具有 Markdown 支持的发行说明

Response:

  1. { "tag_name": "1.0.0", "description": "Amazing release. Wow" }

Update a release

更新给定发行版的发行说明.

  1. PUT /projects/:id/repository/tags/:tag_name/release

Parameters:

  • id (必填)-经过身份验证的用户拥有的项目的 ID 或
  • tag_name (必需)-标签的名称
  • description (必需)-具有 Markdown 支持的发行说明

Response:

  1. { "tag_name": "1.0.0", "description": "Amazing release. Wow" }