Эта версия GitHub Enterprise Server была прекращена 2025-06-19. Исправления выпускаться не будут даже при критических проблемах безопасности. Для повышения производительности, повышения безопасности и новых функций выполните обновление до последней версии GitHub Enterprise Server. Чтобы получить справку по обновлению, обратитесь в службу поддержки GitHub Enterprise.
Конечные точки REST API для сред предварительного получения
Используйте REST API для создания, перечисления, обновления и удаления сред для перехватчики предварительного получения.
Сведения о средах предварительного получения
Эти конечные точки доступны только администраторам сайта, прошедшим проверку подлинности. Обычные 404 пользователи получат ответ.
Примечание.
Эти конечные точки поддерживают проверку подлинности только с помощью personal access token (classic). Дополнительные сведения см. в разделе Управление личными маркерами доступа.
Атрибуты объектов
Среда предварительного получения
| Имя. | Тип | Описание | 
|---|---|---|
name | string | Имя приложения, отображаемое в пользовательском интерфейсе. | 
image_url | string | URL-адрес архива Tarball, который будет скачан и извлечен. | 
default_environment | boolean | Является ли это среда по умолчанию, которая поставляется с GitHub. | 
download | object | Состояние скачивания этой среды. | 
hooks_count | integer | Количество перехватчиков предварительного получения, использующих эту среду. | 
Скачивание среды предварительного получения
| Имя. | Тип | Описание | 
|---|---|---|
state | string | Состояние последнего скачивания. | 
downloaded_at | string | Время начала последнего скачивания. | 
message | string | В случае неудачи будут выданы все сообщения об ошибках. | 
Возможные значения для state: not_started, in_progress, success и failed.
List pre-receive environments
Подробные маркеры доступа для "List pre-receive environments
Эта конечная точка не работает с маркерами доступа пользователей приложения GitHub, маркерами доступа к установке приложения GitHub или точными личными маркерами доступа.
Параметры для "List pre-receive environments"
| Имя., Тип, Description | 
|---|
accept string Setting to   | 
| Имя., Тип, Description | 
|---|
per_page integer The number of results per page (max 100). For more information, see "Using pagination in the REST API." По умолчанию.:   | 
page integer The page number of the results to fetch. For more information, see "Using pagination in the REST API." По умолчанию.:   | 
direction string The direction to sort the results by. По умолчанию.:  Возможные значения:   | 
sort string По умолчанию.:  Возможные значения:   | 
Коды состояния http-ответа для "List pre-receive environments"
| Код состояния | Описание | 
|---|---|
200 | OK  | 
Примеры кода для "List pre-receive environments"
Пример запроса
curl -L \
  -H "Accept: application/vnd.github+json" \
  -H "Authorization: Bearer <YOUR-TOKEN>" \
  -H "X-GitHub-Api-Version: 2022-11-28" \
  http(s)://HOSTNAME/api/v3/admin/pre-receive-environmentsResponse
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
    }
  }
]Create a pre-receive environment
Подробные маркеры доступа для "Create a pre-receive environment
Эта конечная точка не работает с маркерами доступа пользователей приложения GitHub, маркерами доступа к установке приложения GitHub или точными личными маркерами доступа.
Параметры для "Create a pre-receive environment"
| Имя., Тип, Description | 
|---|
accept string Setting to   | 
| Имя., Тип, Description | 
|---|
name string Обязательное полеThe new pre-receive environment's name.  | 
image_url string Обязательное полеURL from which to download a tarball of this environment.  | 
Коды состояния http-ответа для "Create a pre-receive environment"
| Код состояния | Описание | 
|---|---|
201 | Created  | 
Примеры кода для "Create a pre-receive environment"
Пример запроса
curl -L \
  -X POST \
  -H "Accept: application/vnd.github+json" \
  -H "Authorization: Bearer <YOUR-TOKEN>" \
  -H "X-GitHub-Api-Version: 2022-11-28" \
  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
  }
}Get a pre-receive environment
Подробные маркеры доступа для "Get a pre-receive environment
Эта конечная точка не работает с маркерами доступа пользователей приложения GitHub, маркерами доступа к установке приложения GitHub или точными личными маркерами доступа.
Параметры для "Get a pre-receive environment"
| Имя., Тип, Description | 
|---|
accept string Setting to   | 
| Имя., Тип, Description | 
|---|
pre_receive_environment_id integer Обязательное полеThe unique identifier of the pre-receive environment.  | 
Коды состояния http-ответа для "Get a pre-receive environment"
| Код состояния | Описание | 
|---|---|
200 | OK  | 
Примеры кода для "Get a pre-receive environment"
Пример запроса
curl -L \
  -H "Accept: application/vnd.github+json" \
  -H "Authorization: Bearer <YOUR-TOKEN>" \
  -H "X-GitHub-Api-Version: 2022-11-28" \
  http(s)://HOSTNAME/api/v3/admin/pre-receive-environments/PRE_RECEIVE_ENVIRONMENT_IDResponse
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
  }
}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.
Подробные маркеры доступа для "Update a pre-receive environment
Эта конечная точка не работает с маркерами доступа пользователей приложения GitHub, маркерами доступа к установке приложения GitHub или точными личными маркерами доступа.
Параметры для "Update a pre-receive environment"
| Имя., Тип, Description | 
|---|
accept string Setting to   | 
| Имя., Тип, Description | 
|---|
pre_receive_environment_id integer Обязательное полеThe unique identifier of the pre-receive environment.  | 
| Имя., Тип, Description | 
|---|
name string This pre-receive environment's new name.  | 
image_url string URL from which to download a tarball of this environment.  | 
Коды состояния http-ответа для "Update a pre-receive environment"
| Код состояния | Описание | 
|---|---|
200 | OK  | 
422 | Client Errors  | 
Примеры кода для "Update a pre-receive environment"
Пример запроса
curl -L \
  -X PATCH \
  -H "Accept: application/vnd.github+json" \
  -H "Authorization: Bearer <YOUR-TOKEN>" \
  -H "X-GitHub-Api-Version: 2022-11-28" \
  http(s)://HOSTNAME/api/v3/admin/pre-receive-environments/PRE_RECEIVE_ENVIRONMENT_ID \
  -d '{"name":"DevTools Hook Env","image_url":"https://my_file_server/path/to/devtools_env.tar.gz"}'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
  }
}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
 
Подробные маркеры доступа для "Delete a pre-receive environment
Эта конечная точка не работает с маркерами доступа пользователей приложения GitHub, маркерами доступа к установке приложения GitHub или точными личными маркерами доступа.
Параметры для "Delete a pre-receive environment"
| Имя., Тип, Description | 
|---|
accept string Setting to   | 
| Имя., Тип, Description | 
|---|
pre_receive_environment_id integer Обязательное полеThe unique identifier of the pre-receive environment.  | 
Коды состояния http-ответа для "Delete a pre-receive environment"
| Код состояния | Описание | 
|---|---|
204 | No Content  | 
422 | Client Errors  | 
Примеры кода для "Delete a pre-receive environment"
Пример запроса
curl -L \
  -X DELETE \
  -H "Accept: application/vnd.github+json" \
  -H "Authorization: Bearer <YOUR-TOKEN>" \
  -H "X-GitHub-Api-Version: 2022-11-28" \
  http(s)://HOSTNAME/api/v3/admin/pre-receive-environments/PRE_RECEIVE_ENVIRONMENT_IDResponse
Status: 204Start 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
 
Подробные маркеры доступа для "Start a pre-receive environment download
Эта конечная точка не работает с маркерами доступа пользователей приложения GitHub, маркерами доступа к установке приложения GitHub или точными личными маркерами доступа.
Параметры для "Start a pre-receive environment download"
| Имя., Тип, Description | 
|---|
accept string Setting to   | 
| Имя., Тип, Description | 
|---|
pre_receive_environment_id integer Обязательное полеThe unique identifier of the pre-receive environment.  | 
Коды состояния http-ответа для "Start a pre-receive environment download"
| Код состояния | Описание | 
|---|---|
202 | Accepted  | 
422 | Client Errors  | 
Примеры кода для "Start a pre-receive environment download"
Пример запроса
curl -L \
  -X POST \
  -H "Accept: application/vnd.github+json" \
  -H "Authorization: Bearer <YOUR-TOKEN>" \
  -H "X-GitHub-Api-Version: 2022-11-28" \
  http(s)://HOSTNAME/api/v3/admin/pre-receive-environments/PRE_RECEIVE_ENVIRONMENT_ID/downloadsResponse
Status: 202{
  "url": "https://github.example.com/api/v3/admin/pre-receive-environments/3/downloads/latest",
  "state": "not_started",
  "downloaded_at": null,
  "message": null
}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.
Подробные маркеры доступа для "Get the download status for a pre-receive environment
Эта конечная точка не работает с маркерами доступа пользователей приложения GitHub, маркерами доступа к установке приложения GitHub или точными личными маркерами доступа.
Параметры для "Get the download status for a pre-receive environment"
| Имя., Тип, Description | 
|---|
accept string Setting to   | 
| Имя., Тип, Description | 
|---|
pre_receive_environment_id integer Обязательное полеThe unique identifier of the pre-receive environment.  | 
Коды состояния http-ответа для "Get the download status for a pre-receive environment"
| Код состояния | Описание | 
|---|---|
200 | OK  | 
Примеры кода для "Get the download status for a pre-receive environment"
Пример запроса
curl -L \
  -H "Accept: application/vnd.github+json" \
  -H "Authorization: Bearer <YOUR-TOKEN>" \
  -H "X-GitHub-Api-Version: 2022-11-28" \
  http(s)://HOSTNAME/api/v3/admin/pre-receive-environments/PRE_RECEIVE_ENVIRONMENT_ID/downloads/latestResponse
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
}