{{< details >}}
- Tier: 基础版, 专业版, 旗舰版
- Offering: JihuLab.com, 私有化部署
{{< /details >}}
列出所有部署令牌
{{< details >}}
- Tier: 基础版, 专业版, 旗舰版
- Offering: 私有化部署
{{< /details >}}
获取整个极狐 GitLab 实例中的所有部署令牌的列表。此端点需要管理员访问权限。
GET /deploy_tokens
参数:
属性 | 类型 | 必需 | 描述 |
---|---|---|---|
active |
boolean | No | 通过活动状态进行限制。 |
请求示例:
curl --header "PRIVATE-TOKEN: <your_access_token>" \
--url "https://gitlab.example.com/api/v4/deploy_tokens"
响应示例:
[
{
"id": 1,
"name": "MyToken",
"username": "gitlab+deploy-token-1",
"expires_at": "2020-02-14T00:00:00.000Z",
"revoked": false,
"expired": false,
"scopes": [
"read_repository",
"read_registry"
]
}
]
项目部署令牌
项目部署令牌 API 端点至少需要项目的维护者角色。
列出项目部署令牌
获取项目的部署令牌列表。
GET /projects/:id/deploy_tokens
参数:
属性 | 类型 | 必需 | 描述 |
---|---|---|---|
id |
integer/string | Yes | 项目的 ID 或 URL 编码路径。 |
active |
boolean | No | 通过活动状态进行限制。 |
请求示例:
curl --header "PRIVATE-TOKEN: <your_access_token>" \
--url "https://gitlab.example.com/api/v4/projects/1/deploy_tokens"
响应示例:
[
{
"id": 1,
"name": "MyToken",
"username": "gitlab+deploy-token-1",
"expires_at": "2020-02-14T00:00:00.000Z",
"revoked": false,
"expired": false,
"scopes": [
"read_repository",
"read_registry"
]
}
]
获取项目部署令牌
通过 ID 获取单个项目的部署令牌。
GET /projects/:id/deploy_tokens/:token_id
参数:
属性 | 类型 | 必需 | 描述 |
---|---|---|---|
id |
integer/string | Yes | 项目的 ID 或 URL 编码路径。 |
token_id |
integer | Yes | 部署令牌的 ID |
请求示例:
curl --header "PRIVATE-TOKEN: <your_access_token>" \
--url "https://gitlab.example.com/api/v4/projects/1/deploy_tokens/1"
响应示例:
{
"id": 1,
"name": "MyToken",
"username": "gitlab+deploy-token-1",
"expires_at": "2020-02-14T00:00:00.000Z",
"revoked": false,
"expired": false,
"scopes": [
"read_repository",
"read_registry"
]
}
创建项目部署令牌
为项目创建一个新的部署令牌。
POST /projects/:id/deploy_tokens
参数:
属性 | 类型 | 必需 | 描述 |
---|---|---|---|
id |
integer/string | Yes | 项目的 ID 或 URL 编码路径。 |
name |
string | Yes | 新部署令牌的名称 |
scopes |
array of strings | Yes | 指定部署令牌的范围。必须至少包含 read_repository 、read_registry 、write_registry 、read_package_registry 或 write_package_registry 中的一个。 |
expires_at |
datetime | No | 部署令牌的到期日期。如果没有提供值,则不会过期。预期格式为 ISO 8601 (2019-03-15T08:00:00Z ) |
username |
string | No | 部署令牌的用户名。默认为 gitlab+deploy-token-{n}
|
请求示例:
curl --request POST \
--header "PRIVATE-TOKEN: <your_access_token>" \
--header "Content-Type: application/json" \
--data '{"name": "My deploy token", "expires_at": "2021-01-01", "username": "custom-user", "scopes": ["read_repository"]}' \
--url "https://gitlab.example.com/api/v4/projects/5/deploy_tokens/"
响应示例:
{
"id": 1,
"name": "My deploy token",
"username": "custom-user",
"expires_at": "2021-01-01T00:00:00.000Z",
"token": "jMRvtPNxrn3crTAGukpZ",
"revoked": false,
"expired": false,
"scopes": [
"read_repository"
]
}
删除项目部署令牌
从项目中移除一个部署令牌。
DELETE /projects/:id/deploy_tokens/:token_id
参数:
属性 | 类型 | 必需 | 描述 |
---|---|---|---|
id |
integer/string | Yes | 项目的 ID 或 URL 编码路径。 |
token_id |
integer | Yes | 部署令牌的 ID |
请求示例:
curl --request DELETE \
--header "PRIVATE-TOKEN: <your_access_token>" \
--url "https://gitlab.example.com/api/v4/projects/5/deploy_tokens/13"
群组部署令牌
拥有至少群组维护者角色的用户可以列出群组部署令牌。只有群组所有者可以创建和删除群组部署令牌。
列出群组部署令牌
获取群组的部署令牌列表。
GET /groups/:id/deploy_tokens
参数:
属性 | 类型 | 必需 | 描述 |
---|---|---|---|
id |
integer/string | Yes | 群组的 ID 或 URL 编码路径。 |
active |
boolean | No | 通过活动状态进行限制。 |
请求示例:
curl --header "PRIVATE-TOKEN: <your_access_token>" \
--url "https://gitlab.example.com/api/v4/groups/1/deploy_tokens"
响应示例:
[
{
"id": 1,
"name": "MyToken",
"username": "gitlab+deploy-token-1",
"expires_at": "2020-02-14T00:00:00.000Z",
"revoked": false,
"expired": false,
"scopes": [
"read_repository",
"read_registry"
]
}
]
获取群组部署令牌
通过 ID 获取单个群组的部署令牌。
GET /groups/:id/deploy_tokens/:token_id
参数:
属性 | 类型 | 必需 | 描述 |
---|---|---|---|
id |
integer/string | Yes | 群组的 ID 或 URL 编码路径。 |
token_id |
integer | Yes | 部署令牌的 ID |
请求示例:
curl --header "PRIVATE-TOKEN: <your_access_token>" \
--url "https://gitlab.example.com/api/v4/groups/1/deploy_tokens/1"
响应示例:
{
"id": 1,
"name": "MyToken",
"username": "gitlab+deploy-token-1",
"expires_at": "2020-02-14T00:00:00.000Z",
"revoked": false,
"expired": false,
"scopes": [
"read_repository",
"read_registry"
]
}
创建群组部署令牌
为群组创建一个新的部署令牌。
POST /groups/:id/deploy_tokens
参数:
属性 | 类型 | 必需 | 描述 |
---|---|---|---|
id |
integer/string | Yes | 群组的 ID 或 URL 编码路径。 |
name |
string | Yes | 新部署令牌的名称 |
scopes |
array of strings | Yes | 指定部署令牌的范围。必须至少包含 read_repository 、read_registry 、write_registry 、read_package_registry 或 write_package_registry 中的一个。 |
expires_at |
datetime | No | 部署令牌的到期日期。如果没有提供值,则不会过期。预期格式为 ISO 8601 (2019-03-15T08:00:00Z ) |
username |
string | No | 部署令牌的用户名。默认为 gitlab+deploy-token-{n}
|
请求示例:
curl --request POST \
--header "PRIVATE-TOKEN: <your_access_token>" \
--header "Content-Type: application/json" \
--data '{"name": "My deploy token", "expires_at": "2021-01-01", "username": "custom-user", "scopes": ["read_repository"]}' \
--url "https://gitlab.example.com/api/v4/groups/5/deploy_tokens/"
响应示例:
{
"id": 1,
"name": "My deploy token",
"username": "custom-user",
"expires_at": "2021-01-01T00:00:00.000Z",
"token": "jMRvtPNxrn3crTAGukpZ",
"revoked": false,
"expired": false,
"scopes": [
"read_registry"
]
}
删除群组部署令牌
从群组中移除一个部署令牌。
DELETE /groups/:id/deploy_tokens/:token_id
参数:
属性 | 类型 | 必需 | 描述 |
---|---|---|---|
id |
integer/string | Yes | 群组的 ID 或 URL 编码路径。 |
token_id |
integer | Yes | 部署令牌的 ID |
请求示例:
curl --request DELETE \
--header "PRIVATE-TOKEN: <your_access_token>" \
--url "https://gitlab.example.com/api/v4/groups/5/deploy_tokens/13"