{{< details >}}
- Tier: 基础版,专业版,旗舰版
- Offering: JihuLab.com,私有化部署
{{< /details >}}
管理 极狐GitLab Pages 的端点。
必须启用极狐GitLab Pages 功能才能使用这些端点。了解更多关于管理和使用此功能的信息。
取消发布页面
{{< history >}}
- 在极狐GitLab 17.9 中,最小所需角色从管理员访问变更为维护者角色。
{{< /history >}}
先决条件:
- 您必须至少具有项目的维护者角色。
移除页面。
DELETE /projects/:id/pages
属性 | 类型 | 是否必须 | 描述 |
---|---|---|---|
id |
integer/string | 是 | 项目的 ID 或 URL 编码路径 |
curl --request 'DELETE' --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/2/pages"
获取项目的页面设置
{{< history >}}
- 引入于GitLab 16.8。
{{< /history >}}
先决条件:
- 您必须至少具有项目的维护者角色。
列出项目的页面设置。
GET /projects/:id/pages
支持的属性:
属性 | 类型 | 是否必须 | 描述 |
---|---|---|---|
id |
integer/string | 是 | 项目的 ID 或 URL 编码路径 |
如果成功,将返回 200
以及以下响应属性:
属性 | 类型 | 描述 |
---|---|---|
url |
string | 访问此项目页面的 URL。 |
is_unique_domain_enabled |
boolean | 如果启用了 独特域名。 |
force_https |
boolean | 如果项目设置为强制 HTTPS,则为 true 。 |
deployments[] |
array | 当前活动部署的列表。 |
primary_domain |
string | 将所有页面请求重定向到的主域名。Introduced in GitLab 17.8. |
deployments[] 属性 |
类型 | 描述 |
---|---|---|
created_at |
date | 部署创建的日期。 |
url |
string | 此部署的 URL。 |
path_prefix |
string | 使用 并行部署 时的部署路径前缀。 |
root_directory |
string | 根目录。 |
示例请求:
curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/2/pages"
示例响应:
{
"url": "http://html-root-4160ce5f0e9a6c90ccb02755b7fc80f5a2a09ffbb1976cf80b653.pages.gdk.test:3010",
"is_unique_domain_enabled": true,
"force_https": false,
"deployments": [
{
"created_at": "2024-01-05T18:58:14.916Z",
"url": "http://html-root-4160ce5f0e9a6c90ccb02755b7fc80f5a2a09ffbb1976cf80b653.pages.gdk.test:3010/",
"path_prefix": "",
"root_directory": null
},
{
"created_at": "2024-01-05T18:58:46.042Z",
"url": "http://html-root-4160ce5f0e9a6c90ccb02755b7fc80f5a2a09ffbb1976cf80b653.pages.gdk.test:3010/mr3",
"path_prefix": "mr3",
"root_directory": null
}
],
"primary_domain": null
}
更新项目的页面设置
{{< history >}}
- 引入于极狐GitLab 17.0。
- 在极狐GitLab 17.9 中,最小所需角色从管理员访问变更为维护者角色。
{{< /history >}}
先决条件:
- 您必须至少具有项目的维护者角色。
更新项目的页面设置。
PATCH /projects/:id/pages
支持的属性:
属性 | 类型 | 是否必须 | 描述 |
---|---|---|---|
id |
integer/string | 是 | 项目的 ID 或 URL 编码路径 |
pages_unique_domain_enabled |
boolean | 否 | 是否使用独特域名 |
pages_https_only |
boolean | 否 | 是否强制使用 HTTPS |
pages_primary_domain |
string | 否 | 从现有分配的域名中设置主域名以重定向所有页面请求。引入于极狐GitLab 17.8。 |
如果成功,将返回 200
以及以下响应属性:
属性 | 类型 | 描述 |
---|---|---|
url |
string | 访问此项目页面的 URL。 |
is_unique_domain_enabled |
boolean | 如果启用了 独特域名。 |
force_https |
boolean | 如果项目设置为强制 HTTPS,则为 true 。 |
deployments[] |
array | 当前活动部署的列表。 |
primary_domain |
string | 将所有页面请求重定向到的主域名。Introduced in GitLab 17.8. |
deployments[] 属性 |
类型 | 描述 |
---|---|---|
created_at |
date | 部署创建的日期。 |
url |
string | 此部署的 URL。 |
path_prefix |
string | 使用 并行部署 时的部署路径前缀。 |
root_directory |
string | 根目录。 |
示例请求:
curl --request PATCH \
--header "PRIVATE-TOKEN: <your_access_token>" \
--url "https://gitlab.example.com/api/v4/projects/:id/pages" \
--form 'pages_unique_domain_enabled=true' \
--form 'pages_https_only=true' \
--form 'pages_primary_domain=https://custom.example.com'
示例响应:
{
"url": "http://html-root-4160ce5f0e9a6c90ccb02755b7fc80f5a2a09ffbb1976cf80b653.pages.gdk.test:3010",
"is_unique_domain_enabled": true,
"force_https": false,
"deployments": [
{
"created_at": "2024-01-05T18:58:14.916Z",
"url": "http://html-root-4160ce5f0e9a6c90ccb02755b7fc80f5a2a09ffbb1976cf80b653.pages.gdk.test:3010/",
"path_prefix": "",
"root_directory": null
},
{
"created_at": "2024-01-05T18:58:46.042Z",
"url": "http://html-root-4160ce5f0e9a6c90ccb02755b7fc80f5a2a09ffbb1976cf80b653.pages.gdk.test:3010/mr3",
"path_prefix": "mr3",
"root_directory": null
}
],
"primary_domain": null
}