Skip to main content
Frecuentemente publicamos actualizaciones de nuestra documentación. Es posible que la traducción de esta página esté en curso. Para conocer la información más actual, visita la documentación en inglés. Si existe un problema con las traducciones en esta página, por favor infórmanos.

Esta versión de GitHub Enterprise se discontinuó el 2022-06-03. No se realizarán lanzamientos de patch, ni siquiera para problemas de seguridad críticos. Para obtener un mejor desempeño, más seguridad y nuevas características, actualiza a la última versión de GitHub Enterprise. Para obtener ayuda con la actualización, contacta al soporte de 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.

Pre-receive Environments

La API de Ambientes de Pre-recepción te permite crear, listar, actualizar y borrar ambientes para los ganchos de pre-recepción.

Solo se encuentra disponible para los administradores de sitio autenticados. Los usuarios normales recibirán una respuesta 404 si intentan acceder a ella.

Atributos de objeto

Ambiente de pre-recepción

NombreTipoDescripción
name (nombre)secuenciaEl nombre del ambiente como se muestra en la IU.
image_urlsecuenciaLa URL del tarball que se descargará y extraerá.
default_environmentbooleanSi este es el ambiente predeterminado que viene con GitHub Enterprise Server o no.
downloadobjetoEl estado de descarga de este ambiente.
hooks_countnúmeroLa cantidad de ganchos de pre-recepción que utilizan este ambiente.

Descarga del Ambiente de Pre-recepción

NombreTipoDescripción
statesecuenciaEl estado de la mayoría de las descargas recientes.
downloaded_atsecuenciaLa hora en la cual iniciaron la mayoría de las descrgas recientes.
messagesecuenciaCuando algo falla, este tendrá cualquier mensaje de error que se haya producido.

Los valores posibles para state son not_started, in_progress, success, failed.

List pre-receive environments

Parámetros

Encabezados
Nombre, Tipo, Descripción
acceptstring

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

Ver aviso de previsualización
Parámetros de consulta
Nombre, Tipo, Descripción
per_pageinteger

The number of results per page (max 100).

Predeterminado: 30

pageinteger

Page number of the results to fetch.

Predeterminado: 1

directionstring

The direction to sort the results by.

Predeterminado: desc

Puede ser una de las siguientes: asc, desc

sortstring

Predeterminado: created

Puede ser una de las siguientes: created, updated, name

Códigos de estado de respuesta HTTP

Código de estadoDescripción
200

OK

Ejemplos de código

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 } } ]

Aviso de previsualización

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

Parámetros

Encabezados
Nombre, Tipo, Descripción
acceptstring

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

Ver aviso de previsualización
Parámetros de cuerpo
Nombre, Tipo, Descripción
namestringRequerido

The new pre-receive environment's name.

image_urlstringRequerido

URL from which to download a tarball of this environment.

Códigos de estado de respuesta HTTP

Código de estadoDescripción
201

Created

Ejemplos de código

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 } }

Aviso de previsualización

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

Parámetros

Encabezados
Nombre, Tipo, Descripción
acceptstring

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

Ver aviso de previsualización
Parámetros de ruta
Nombre, Tipo, Descripción
pre_receive_environment_idintegerRequerido

The unique identifier of the pre-receive environment.

Códigos de estado de respuesta HTTP

Código de estadoDescripción
200

OK

Ejemplos de código

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 } }

Aviso de previsualización

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.

Parámetros

Encabezados
Nombre, Tipo, Descripción
acceptstring

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

Ver aviso de previsualización
Parámetros de ruta
Nombre, Tipo, Descripción
pre_receive_environment_idintegerRequerido

The unique identifier of the pre-receive environment.

Parámetros de cuerpo
Nombre, Tipo, Descripción
namestring

This pre-receive environment's new name.

image_urlstring

URL from which to download a tarball of this environment.

Códigos de estado de respuesta HTTP

Código de estadoDescripción
200

OK

422

Client Errors

Ejemplos de código

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 } }

Aviso de previsualización

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

Parámetros

Encabezados
Nombre, Tipo, Descripción
acceptstring

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

Ver aviso de previsualización
Parámetros de ruta
Nombre, Tipo, Descripción
pre_receive_environment_idintegerRequerido

The unique identifier of the pre-receive environment.

Códigos de estado de respuesta HTTP

Código de estadoDescripción
204

No Content

422

Client Errors

Ejemplos de código

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

Aviso de previsualización

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

Parámetros

Encabezados
Nombre, Tipo, Descripción
acceptstring

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

Ver aviso de previsualización
Parámetros de ruta
Nombre, Tipo, Descripción
pre_receive_environment_idintegerRequerido

The unique identifier of the pre-receive environment.

Códigos de estado de respuesta HTTP

Código de estadoDescripción
202

Accepted

422

Client Errors

Ejemplos de código

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 }

Aviso de previsualización

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.

Parámetros

Encabezados
Nombre, Tipo, Descripción
acceptstring

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

Ver aviso de previsualización
Parámetros de ruta
Nombre, Tipo, Descripción
pre_receive_environment_idintegerRequerido

The unique identifier of the pre-receive environment.

Códigos de estado de respuesta HTTP

Código de estadoDescripción
200

OK

Ejemplos de código

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 }

Aviso de previsualización

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