- 获取项目的 CI/CD 作业令牌 访问设置
- 更新项目的 CI/CD 作业令牌 访问设置
- 获取项目的 CI/CD 作业令牌 入站允许列表
- 将项目添加到 CI/CD 作业令牌 入站允许列表
- 从 CI/CD 作业令牌 入站允许列表中移除项目
- 获取项目的 CI/CD 作业令牌 群组允许列表
- 将群组添加到 CI/CD 作业令牌 允许列表
- 从 CI/CD 作业令牌 允许列表中移除群组
{{< details >}}
- Tier: 基础版, 专业版, 旗舰版
- Offering: JihuLab.com, 私有化部署
{{< /details >}}
你可以阅读更多关于 CI/CD 作业令牌 的信息。
{{< alert type=”note” >}}
所有对 CI/CD 作业令牌 scope API 端点的请求必须进行 认证。认证用户必须至少具有项目的维护者角色。
{{< /alert >}}
获取项目的 CI/CD 作业令牌 访问设置
获取项目的 CI/CD 作业令牌 访问设置(作业令牌 scope)。
GET /projects/:id/job_token_scope
支持的属性:
属性 | 类型 | 必需 | 描述 |
---|---|---|---|
id |
integer/string | 是 | 项目的 ID 或 URL 编码路径。 |
如果成功,将返回 200
和以下响应属性:
属性 | 类型 | 描述 |
---|---|---|
inbound_enabled |
boolean | 指示是否启用了 限制访问 到 此项目 设置。如果禁用,则 所有项目都可以访问。 |
outbound_enabled |
boolean | 指示在此项目中生成的 CI/CD 作业令牌 是否可以访问其他项目。在极狐GitLab 18.0 中弃用并计划移除。 |
示例请求:
curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/1/job_token_scope"
示例响应:
{
"inbound_enabled": true,
"outbound_enabled": false
}
更新项目的 CI/CD 作业令牌 访问设置
{{< history >}}
- 允许使用 CI_JOB_TOKEN 访问此项目 设置在极狐GitLab 16.3 中被重命名为 限制访问 到 此项目。
{{< /history >}}
更新项目的 限制访问 到 此项目 设置(作业令牌 scope)。
PATCH /projects/:id/job_token_scope
支持的属性:
属性 | 类型 | 必需 | 描述 |
---|---|---|---|
id |
integer/string | 是 | 项目的 ID 或 URL 编码路径。 |
enabled |
boolean | 是 | 指示是否应启用 限制访问 到 此项目 设置。 |
如果成功,将返回 204
并且没有响应主体。
示例请求:
curl --request PATCH \
--url "https://gitlab.example.com/api/v4/projects/1/job_token_scope" \
--header 'PRIVATE-TOKEN: <your_access_token>' \
--header 'Content-Type: application/json' \
--data '{ "enabled": false }'
获取项目的 CI/CD 作业令牌 入站允许列表
获取项目的 CI/CD 作业令牌 入站允许列表(作业令牌 scope)。
GET /projects/:id/job_token_scope/allowlist
支持的属性:
属性 | 类型 | 必需 | 描述 |
---|---|---|---|
id |
integer/string | 是 | 项目的 ID 或 URL 编码路径。 |
此端点支持 基于偏移量的分页。
如果成功,将返回 200
和每个项目具有有限字段的项目列表。
示例请求:
curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/1/job_token_scope/allowlist"
示例响应:
[
{
"id": 4,
"description": null,
"name": "Diaspora Client",
"name_with_namespace": "Diaspora / Diaspora Client",
"path": "diaspora-client",
"path_with_namespace": "diaspora/diaspora-client",
"created_at": "2013-09-30T13:46:02Z",
"default_branch": "main",
"tag_list": [
"example",
"disapora client"
],
"topics": [
"example",
"disapora client"
],
"ssh_url_to_repo": "git@gitlab.example.com:diaspora/diaspora-client.git",
"http_url_to_repo": "https://gitlab.example.com/diaspora/diaspora-client.git",
"web_url": "https://gitlab.example.com/diaspora/diaspora-client",
"avatar_url": "https://gitlab.example.com/uploads/project/avatar/4/uploads/avatar.png",
"star_count": 0,
"last_activity_at": "2013-09-30T13:46:02Z",
"namespace": {
"id": 2,
"name": "Diaspora",
"path": "diaspora",
"kind": "group",
"full_path": "diaspora",
"parent_id": null,
"avatar_url": null,
"web_url": "https://gitlab.example.com/diaspora"
}
},
{
...
}
]
将项目添加到 CI/CD 作业令牌 入站允许列表
将项目添加到项目的 CI/CD 作业令牌 入站允许列表。
POST /projects/:id/job_token_scope/allowlist
支持的属性:
属性 | 类型 | 必需 | 描述 |
---|---|---|---|
id |
integer/string | 是 | 项目的 ID 或 URL 编码路径。 |
target_project_id |
integer | 是 | 添加到 CI/CD 作业令牌 入站允许列表中的项目的 ID。 |
如果成功,将返回 201
和以下响应属性:
属性 | 类型 | 描述 |
---|---|---|
source_project_id |
integer | 包含 CI/CD 作业令牌 入站允许列表的项目的 ID。 |
target_project_id |
integer | 被添加到源项目入站允许列表中的项目 ID。 |
示例请求:
curl --request POST \
--url "https://gitlab.example.com/api/v4/projects/1/job_token_scope/allowlist" \
--header 'PRIVATE-TOKEN: <your_access_token>' \
--header 'Content-Type: application/json' \
--data '{ "target_project_id": 2 }'
示例响应:
{
"source_project_id": 1,
"target_project_id": 2
}
从 CI/CD 作业令牌 入站允许列表中移除项目
从项目的 CI/CD 作业令牌 入站允许列表 中移除项目。
DELETE /projects/:id/job_token_scope/allowlist/:target_project_id
支持的属性:
属性 | 类型 | 必需 | 描述 |
---|---|---|---|
id |
integer/string | 是 | 项目的 ID 或 URL 编码路径。 |
target_project_id |
integer | 是 | 从 CI/CD 作业令牌 入站允许列表中移除的项目 ID。 |
如果成功,将返回 204
并且没有响应主体。
示例请求:
curl --request DELETE \
--url "https://gitlab.example.com/api/v4/projects/1/job_token_scope/allowlist/2" \
--header 'PRIVATE-TOKEN: <your_access_token>' \
--header 'Content-Type: application/json'
获取项目的 CI/CD 作业令牌 群组允许列表
获取项目的 CI/CD 作业令牌 群组允许列表(作业令牌 scope)。
GET /projects/:id/job_token_scope/groups_allowlist
支持的属性:
属性 | 类型 | 必需 | 描述 |
---|---|---|---|
id |
integer/string | 是 | 项目的 ID 或 URL 编码路径。 |
此端点支持 基于偏移量的分页。
如果成功,将返回 200
和每个项目具有有限字段的群组列表。
示例请求:
curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/1/job_token_scope/groups_allowlist"
示例响应:
[
{
"id": 4,
"web_url": "https://gitlab.example.com/groups/diaspora/diaspora-group",
"name": "namegroup"
},
{
...
}
]
将群组添加到 CI/CD 作业令牌 允许列表
将群组添加到项目的 CI/CD 作业令牌 允许列表。
POST /projects/:id/job_token_scope/groups_allowlist
支持的属性:
属性 | 类型 | 必需 | 描述 |
---|---|---|---|
id |
integer/string | 是 | 项目的 ID 或 URL 编码路径。 |
target_group_id |
integer | 是 | 添加到 CI/CD 作业令牌 群组允许列表中的群组 ID。 |
如果成功,将返回 201
和以下响应属性:
属性 | 类型 | 描述 |
---|---|---|
source_project_id |
integer | 包含 CI/CD 作业令牌 入站允许列表的项目的 ID。 |
target_group_id |
integer | 被添加到源项目群组允许列表中的群组 ID。 |
示例请求:
curl --request POST \
--url "https://gitlab.example.com/api/v4/projects/1/job_token_scope/groups_allowlist" \
--header 'PRIVATE-TOKEN: <your_access_token>' \
--header 'Content-Type: application/json' \
--data '{ "target_group_id": 2 }'
示例响应:
{
"source_project_id": 1,
"target_group_id": 2
}
从 CI/CD 作业令牌 允许列表中移除群组
从项目的 CI/CD 作业令牌 允许列表中移除群组。
DELETE /projects/:id/job_token_scope/groups_allowlist/:target_group_id
支持的属性:
属性 | 类型 | 必需 | 描述 |
---|---|---|---|
id |
integer/string | 是 | 项目的 ID 或 URL 编码路径。 |
target_group_id |
integer | 是 | 从 CI/CD 作业令牌 群组允许列表中移除的群组 ID。 |
如果成功,将返回 204
并且没有响应主体。
示例请求:
curl --request DELETE \
--url "https://gitlab.example.com/api/v4/projects/1/job_token_scope/groups_allowlist/2" \
--header 'PRIVATE-TOKEN: <your_access_token>' \
--header 'Content-Type: application/json'