Pages API

  • Tier: 基础版,专业版,旗舰版
  • Offering: JihuLab.com,私有化部署

管理 极狐GitLab Pages 的端点。

必须启用极狐GitLab Pages 功能才能使用这些端点。了解更多关于管理使用此功能的信息。

取消发布页面#

History
    • 在极狐GitLab 17.9 中,最小所需角色从管理员访问变更为维护者角色。

先决条件:

  • 您必须至少具有项目的维护者角色。

移除页面。

plaintext
DELETE /projects/:id/pages
属性类型是否必须描述
idinteger/string项目的 ID 或 URL 编码路径
shell
curl --request 'DELETE' --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/2/pages"

获取项目的页面设置#

History
    • 引入于GitLab 16.8。

先决条件:

  • 您必须至少具有项目的维护者角色。

列出项目的页面设置。

plaintext
GET /projects/:id/pages

支持的属性:

属性类型是否必须描述
idinteger/string项目的 ID 或 URL 编码路径

如果成功,将返回 200 以及以下响应属性:

属性类型描述
urlstring访问此项目页面的 URL。
is_unique_domain_enabledboolean如果启用了 独特域名
force_httpsboolean如果项目设置为强制 HTTPS,则为 true
deployments[]array当前活动部署的列表。
primary_domainstring将所有页面请求重定向到的主域名。Introduced in GitLab 17.8.
deployments[] 属性类型描述
created_atdate部署创建的日期。
urlstring此部署的 URL。
path_prefixstring使用 并行部署 时的部署路径前缀。
root_directorystring根目录。

示例请求:

shell
curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/2/pages"

示例响应:

json
1{ 2 "url": "http://html-root-4160ce5f0e9a6c90ccb02755b7fc80f5a2a09ffbb1976cf80b653.pages.gdk.test:3010", 3 "is_unique_domain_enabled": true, 4 "force_https": false, 5 "deployments": [ 6 { 7 "created_at": "2024-01-05T18:58:14.916Z", 8 "url": "http://html-root-4160ce5f0e9a6c90ccb02755b7fc80f5a2a09ffbb1976cf80b653.pages.gdk.test:3010/", 9 "path_prefix": "", 10 "root_directory": null 11 }, 12 { 13 "created_at": "2024-01-05T18:58:46.042Z", 14 "url": "http://html-root-4160ce5f0e9a6c90ccb02755b7fc80f5a2a09ffbb1976cf80b653.pages.gdk.test:3010/mr3", 15 "path_prefix": "mr3", 16 "root_directory": null 17 } 18 ], 19 "primary_domain": null 20}

更新项目的页面设置#

History
    • 引入于极狐GitLab 17.0。
    • 在极狐GitLab 17.9 中,最小所需角色从管理员访问变更为维护者角色。

先决条件:

  • 您必须至少具有项目的维护者角色。

更新项目的页面设置。

plaintext
PATCH /projects/:id/pages

支持的属性:

属性类型是否必须描述
idinteger/string项目的 ID 或 URL 编码路径
pages_unique_domain_enabledboolean是否使用独特域名
pages_https_onlyboolean是否强制使用 HTTPS
pages_primary_domainstring从现有分配的域名中设置主域名以重定向所有页面请求。引入于极狐GitLab 17.8。

如果成功,将返回 200 以及以下响应属性:

属性类型描述
urlstring访问此项目页面的 URL。
is_unique_domain_enabledboolean如果启用了 独特域名
force_httpsboolean如果项目设置为强制 HTTPS,则为 true
deployments[]array当前活动部署的列表。
primary_domainstring将所有页面请求重定向到的主域名。Introduced in GitLab 17.8.
deployments[] 属性类型描述
created_atdate部署创建的日期。
urlstring此部署的 URL。
path_prefixstring使用 并行部署 时的部署路径前缀。
root_directorystring根目录。

示例请求:

shell
1curl --request PATCH \ 2 --header "PRIVATE-TOKEN: <your_access_token>" \ 3 --url "https://gitlab.example.com/api/v4/projects/:id/pages" \ 4 --form 'pages_unique_domain_enabled=true' \ 5 --form 'pages_https_only=true' \ 6 --form 'pages_primary_domain=https://custom.example.com'

示例响应:

json
1{ 2 "url": "http://html-root-4160ce5f0e9a6c90ccb02755b7fc80f5a2a09ffbb1976cf80b653.pages.gdk.test:3010", 3 "is_unique_domain_enabled": true, 4 "force_https": false, 5 "deployments": [ 6 { 7 "created_at": "2024-01-05T18:58:14.916Z", 8 "url": "http://html-root-4160ce5f0e9a6c90ccb02755b7fc80f5a2a09ffbb1976cf80b653.pages.gdk.test:3010/", 9 "path_prefix": "", 10 "root_directory": null 11 }, 12 { 13 "created_at": "2024-01-05T18:58:46.042Z", 14 "url": "http://html-root-4160ce5f0e9a6c90ccb02755b7fc80f5a2a09ffbb1976cf80b653.pages.gdk.test:3010/mr3", 15 "path_prefix": "mr3", 16 "root_directory": null 17 } 18 ], 19 "primary_domain": null 20}