Skip to main content

此版本的 GitHub Enterprise 已停止服务 2022-06-03. 即使针对重大安全问题,也不会发布补丁。 要获得更好的性能、改进的安全性和新功能,请升级到 GitHub Enterprise 的最新版本。 如需升级方面的帮助,请联系 GitHub Enterprise 支持

We've recently moved some of the REST API documentation. If you can't find what you're looking for, you might try the Actions REST API page.

预接收环境

预接收环境 API 允许您创建、列出、更新和� 除预接收挂钩的环境。

它只适用于经过身份验证的站点管理员。普通用户尝试访问它时会收到 404 响应。

对象属性

预接收环境

名称类型描述
name字符串UI 中显示的环境名称。
image_url字符串将要下载并解压缩的 tarball 的 URL。
default_environment布尔值这是否是 GitHub Enterprise Server 附带的默认环境。
download对象此环境的下载状态。
hooks_count整数使用此环境的预接收挂钩数量。

预接收环境下载

名称类型描述
state字符串最近下载的状态。
downloaded_at字符串最近下载开始的时间。
message字符串在失败时生成任何错误消息。

state 的可能值包括 not_startedin_progresssuccessfailed

List pre-receive environments

参数

� �头
名称, 类型, 描述
acceptstring

Setting to application/vnd.github.v3+json is recommended.

查看预览通知
查询参数
名称, 类型, 描述
per_pageinteger

The number of results per page (max 100).

默认值: 30

pageinteger

Page number of the results to fetch.

默认值: 1

directionstring

The direction to sort the results by.

默认值: desc

可以是以下其中之一: asc, desc

sortstring

默认值: created

可以是以下其中之一: created, updated, name

HTTP 响应状态代� �

状态代� �描述
200

OK

代� �示例

get/admin/pre-receive-environments
curl \ -H "Accept: application/vnd.github.v3+json" \ -H "Authorization: token <TOKEN>" \ http(s)://HOSTNAME/api/v3/admin/pre-receive-environments

Response

Status: 200
[ { "id": 1, "name": "Default", "image_url": "githubenterprise://internal", "url": "https://github.example.com/api/v3/admin/pre-receive-environments/1", "html_url": "https://github.example.com/admin/pre-receive-environments/1", "default_environment": true, "created_at": "2016-05-20T11:35:45-05:00", "hooks_count": 14, "download": { "url": "https://github.example.com/api/v3/admin/pre-receive-environments/1/downloads/latest", "state": "not_started", "downloaded_at": "2016-05-26T07:42:53-05:00", "message": null } }, { "id": 2, "name": "DevTools Hook Env", "image_url": "https://my_file_server/path/to/devtools_env.tar.gz", "url": "https://github.example.com/api/v3/admin/pre-receive-environments/2", "html_url": "https://github.example.com/admin/pre-receive-environments/2", "default_environment": false, "created_at": "2016-05-20T11:35:45-05:00", "hooks_count": 1, "download": { "url": "https://github.example.com/api/v3/admin/pre-receive-environments/2/downloads/latest", "state": "success", "downloaded_at": "2016-05-26T07:42:53-05:00", "message": null } } ]

预览通知

APIs for managing pre-receive hooks are currently available for developers to preview. During the preview period, the APIs may change without advance notice.

To access the API you must provide a custom media type in the Accept header:

application/vnd.github.eye-scream-preview

Create a pre-receive environment

参数

� �头
名称, 类型, 描述
acceptstring

Setting to application/vnd.github.v3+json is recommended.

查看预览通知
正文参数
名称, 类型, 描述
namestring必选

The new pre-receive environment's name.

image_urlstring必选

URL from which to download a tarball of this environment.

HTTP 响应状态代� �

状态代� �描述
201

Created

代� �示例

post/admin/pre-receive-environments
curl \ -X POST \ -H "Accept: application/vnd.github.v3+json" \ -H "Authorization: token <TOKEN>" \ http(s)://HOSTNAME/api/v3/admin/pre-receive-environments \ -d '{"name":"DevTools Hook Env","image_url":"https://my_file_server/path/to/devtools_env.tar.gz"}'

Response

Status: 201
{ "id": 2, "name": "DevTools Hook Env", "image_url": "https://my_file_server/path/to/devtools_env.tar.gz", "url": "https://github.example.com/api/v3/admin/pre-receive-environments/2", "html_url": "https://github.example.com/admin/pre-receive-environments/2", "default_environment": false, "created_at": "2016-05-20T11:35:45-05:00", "hooks_count": 1, "download": { "url": "https://github.example.com/api/v3/admin/pre-receive-environments/2/downloads/latest", "state": "not_started", "downloaded_at": null, "message": null } }

预览通知

APIs for managing pre-receive hooks are currently available for developers to preview. During the preview period, the APIs may change without advance notice.

To access the API you must provide a custom media type in the Accept header:

application/vnd.github.eye-scream-preview

Get a pre-receive environment

参数

� �头
名称, 类型, 描述
acceptstring

Setting to application/vnd.github.v3+json is recommended.

查看预览通知
路径参数
名称, 类型, 描述
pre_receive_environment_idinteger必选

The unique identifier of the pre-receive environment.

HTTP 响应状态代� �

状态代� �描述
200

OK

代� �示例

get/admin/pre-receive-environments/{pre_receive_environment_id}
curl \ -H "Accept: application/vnd.github.v3+json" \ -H "Authorization: token <TOKEN>" \ http(s)://HOSTNAME/api/v3/admin/pre-receive-environments/PRE_RECEIVE_ENVIRONMENT_ID

Response

Status: 200
{ "id": 2, "name": "DevTools Hook Env", "image_url": "https://my_file_server/path/to/devtools_env.tar.gz", "url": "https://github.example.com/api/v3/admin/pre-receive-environments/2", "html_url": "https://github.example.com/admin/pre-receive-environments/2", "default_environment": false, "created_at": "2016-05-20T11:35:45-05:00", "hooks_count": 1, "download": { "url": "https://github.example.com/api/v3/admin/pre-receive-environments/2/downloads/latest", "state": "not_started", "downloaded_at": null, "message": null } }

预览通知

APIs for managing pre-receive hooks are currently available for developers to preview. During the preview period, the APIs may change without advance notice.

To access the API you must provide a custom media type in the Accept header:

application/vnd.github.eye-scream-preview

Update a pre-receive environment

You cannot modify the default environment. If you attempt to modify the default environment, you will receive a 422 Unprocessable Entity response.

参数

� �头
名称, 类型, 描述
acceptstring

Setting to application/vnd.github.v3+json is recommended.

查看预览通知
路径参数
名称, 类型, 描述
pre_receive_environment_idinteger必选

The unique identifier of the pre-receive environment.

正文参数
名称, 类型, 描述
namestring

This pre-receive environment's new name.

image_urlstring

URL from which to download a tarball of this environment.

HTTP 响应状态代� �

状态代� �描述
200

OK

422

Client Errors

代� �示例

patch/admin/pre-receive-environments/{pre_receive_environment_id}
curl \ -X PATCH \ -H "Accept: application/vnd.github.v3+json" \ -H "Authorization: token <TOKEN>" \ http(s)://HOSTNAME/api/v3/admin/pre-receive-environments/PRE_RECEIVE_ENVIRONMENT_ID

Response

Status: 200
{ "id": 2, "name": "DevTools Hook Env", "image_url": "https://my_file_server/path/to/devtools_env.tar.gz", "url": "https://github.example.com/api/v3/admin/pre-receive-environments/2", "html_url": "https://github.example.com/admin/pre-receive-environments/2", "default_environment": false, "created_at": "2016-05-20T11:35:45-05:00", "hooks_count": 1, "download": { "url": "https://github.example.com/api/v3/admin/pre-receive-environments/2/downloads/latest", "state": "success", "downloaded_at": "2016-05-26T07:42:53-05:00", "message": null } }

预览通知

APIs for managing pre-receive hooks are currently available for developers to preview. During the preview period, the APIs may change without advance notice.

To access the API you must provide a custom media type in the Accept header:

application/vnd.github.eye-scream-preview

Delete a pre-receive environment

If you attempt to delete an environment that cannot be deleted, you will receive a 422 Unprocessable Entity response.

The possible error messages are:

  • Cannot modify or delete the default environment
  • Cannot delete environment that has hooks
  • Cannot delete environment when download is in progress

参数

� �头
名称, 类型, 描述
acceptstring

Setting to application/vnd.github.v3+json is recommended.

查看预览通知
路径参数
名称, 类型, 描述
pre_receive_environment_idinteger必选

The unique identifier of the pre-receive environment.

HTTP 响应状态代� �

状态代� �描述
204

No Content

422

Client Errors

代� �示例

delete/admin/pre-receive-environments/{pre_receive_environment_id}
curl \ -X DELETE \ -H "Accept: application/vnd.github.v3+json" \ -H "Authorization: token <TOKEN>" \ http(s)://HOSTNAME/api/v3/admin/pre-receive-environments/PRE_RECEIVE_ENVIRONMENT_ID

Response

Status: 204

预览通知

APIs for managing pre-receive hooks are currently available for developers to preview. During the preview period, the APIs may change without advance notice.

To access the API you must provide a custom media type in the Accept header:

application/vnd.github.eye-scream-preview

Start a pre-receive environment download

Triggers a new download of the environment tarball from the environment's image_url. When the download is finished, the newly downloaded tarball will overwrite the existing environment.

If a download cannot be triggered, you will receive a 422 Unprocessable Entity response.

The possible error messages are:

  • Cannot modify or delete the default environment
  • Can not start a new download when a download is in progress

参数

� �头
名称, 类型, 描述
acceptstring

Setting to application/vnd.github.v3+json is recommended.

查看预览通知
路径参数
名称, 类型, 描述
pre_receive_environment_idinteger必选

The unique identifier of the pre-receive environment.

HTTP 响应状态代� �

状态代� �描述
202

Accepted

422

Client Errors

代� �示例

post/admin/pre-receive-environments/{pre_receive_environment_id}/downloads
curl \ -X POST \ -H "Accept: application/vnd.github.v3+json" \ -H "Authorization: token <TOKEN>" \ http(s)://HOSTNAME/api/v3/admin/pre-receive-environments/PRE_RECEIVE_ENVIRONMENT_ID/downloads

Response

Status: 202
{ "url": "https://github.example.com/api/v3/admin/pre-receive-environments/3/downloads/latest", "state": "not_started", "downloaded_at": null, "message": null }

预览通知

APIs for managing pre-receive hooks are currently available for developers to preview. During the preview period, the APIs may change without advance notice.

To access the API you must provide a custom media type in the Accept header:

application/vnd.github.eye-scream-preview

Get the download status for a pre-receive environment

In addition to seeing the download status at the "Get a pre-receive environment" endpoint, there is also this separate endpoint for just the download status.

参数

� �头
名称, 类型, 描述
acceptstring

Setting to application/vnd.github.v3+json is recommended.

查看预览通知
路径参数
名称, 类型, 描述
pre_receive_environment_idinteger必选

The unique identifier of the pre-receive environment.

HTTP 响应状态代� �

状态代� �描述
200

OK

代� �示例

get/admin/pre-receive-environments/{pre_receive_environment_id}/downloads/latest
curl \ -H "Accept: application/vnd.github.v3+json" \ -H "Authorization: token <TOKEN>" \ http(s)://HOSTNAME/api/v3/admin/pre-receive-environments/PRE_RECEIVE_ENVIRONMENT_ID/downloads/latest

Response

Status: 200
{ "url": "https://github.example.com/api/v3/admin/pre-receive-environments/3/downloads/latest", "state": "success", "downloaded_at": "2016-05-26T07:42:53-05:00", "message": null }

预览通知

APIs for managing pre-receive hooks are currently available for developers to preview. During the preview period, the APIs may change without advance notice.

To access the API you must provide a custom media type in the Accept header:

application/vnd.github.eye-scream-preview