Esta versión de GitHub Enterprise Server se discontinuó el 2024-03-26. No se realizarán lanzamientos de patch, ni siquiera para problemas de seguridad críticos. Para obtener rendimiento mejorado, seguridad mejorada y nuevas características, actualice a la versión más reciente de GitHub Enterprise Server. Para obtener ayuda con la actualización, póngase en contacto con el soporte técnico de GitHub Enterprise.
Puntos de conexión de API de REST para enlaces previos a la recepción
Usa la API REST para crear, enumerar, actualizar y eliminar enlaces previos a la recepción.
Acerca de ganchos de pre-recepción
Estos puntos de conexión solo están disponibles para los administradores de sitios autenticados. Los usuarios normales recibirán una respuesta 404
.
Atributos de objeto
Ganchos de pre-recepción
Nombre | Escribir | Descripción |
---|---|---|
name | string | El nombre del gancho. |
script | string | El script que ejecuta el gancho. |
script_repository | object | El repositorio de GitHub en donde se mantiene el script. |
environment | object | El ambiente de pre-recepción en donde se ejecuta el script. |
enforcement | string | El estado de las imposiciones para este gancho. |
allow_downstream_configuration | boolean | Si las imposiciones pueden o no ignorarse a nivel de organización o de repositorio. |
Los valores posibles para la aplicación son enabled
, disabled
y testing
. disabled
indica que no se ejecutará el enlace previo a la recepción. enabled
indica que se ejecutará y rechazará cualquier inserción que dé como resultado un estado distinto a cero. testing
indica que el script se ejecutará pero no rechazará ninguna inserción.
List pre-receive hooks
Parámetros para "List pre-receive hooks"
Nombre, Tipo, Descripción |
---|
accept string Setting to |
Nombre, Tipo, Descripción |
---|
per_page integer The number of results per page (max 100). For more information, see "Using pagination in the REST API." Valor predeterminado: |
page integer The page number of the results to fetch. For more information, see "Using pagination in the REST API." Valor predeterminado: |
direction string The direction to sort the results by. Valor predeterminado: Puede ser uno de los siguientes: |
sort string The property to sort the results by. Valor predeterminado: Puede ser uno de los siguientes: |
Códigos de estado de respuesta HTTP para "List pre-receive hooks"
status code | Descripción |
---|---|
200 | OK |
Ejemplos de código para "List pre-receive hooks"
Ejemplo de solicitud
curl -L \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>" \
http(s)://HOSTNAME/api/v3/admin/pre-receive-hooks
Response
Status: 200
[
{
"id": 1,
"name": "Check Commits",
"enforcement": "disabled",
"script": "scripts/commmit_check.sh",
"script_repository": {
"id": 595,
"full_name": "DevIT/hooks",
"url": "https://github.example.com/api/v3/repos/DevIT/hooks",
"html_url": "https://github.example.com/DevIT/hooks"
},
"environment": {
"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
}
},
"allow_downstream_configuration": false
}
]
Create a pre-receive hook
Parámetros para "Create a pre-receive hook"
Nombre, Tipo, Descripción |
---|
accept string Setting to |
Nombre, Tipo, Descripción |
---|
name string RequeridoThe name of the hook. |
script string RequeridoThe script that the hook runs. |
script_repository object RequeridoThe GitHub repository where the script is kept. |
environment object RequeridoThe pre-receive environment where the script is executed. |
enforcement string The state of enforcement for this hook. default: |
allow_downstream_configuration boolean Whether enforcement can be overridden at the org or repo level. default: |
Códigos de estado de respuesta HTTP para "Create a pre-receive hook"
status code | Descripción |
---|---|
201 | Created |
Ejemplos de código para "Create a pre-receive hook"
Ejemplo de solicitud
curl -L \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>" \
http(s)://HOSTNAME/api/v3/admin/pre-receive-hooks \
-d '{"name":"Check Commits","script":"scripts/commit_check.sh","enforcement":"disabled","allow_downstream_configuration":false,"script_repository":{"full_name":"DevIT/hooks"},"environment":{"id":2}}'
Response
Status: 201
{
"id": 1,
"name": "Check Commits",
"enforcement": "disabled",
"script": "scripts/commmit_check.sh",
"script_repository": {
"id": 595,
"full_name": "DevIT/hooks",
"url": "https://github.example.com/api/v3/repos/DevIT/hooks",
"html_url": "https://github.example.com/DevIT/hooks"
},
"environment": {
"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
}
},
"allow_downstream_configuration": false
}
Get a pre-receive hook
Parámetros para "Get a pre-receive hook"
Nombre, Tipo, Descripción |
---|
accept string Setting to |
Nombre, Tipo, Descripción |
---|
pre_receive_hook_id integer RequeridoThe unique identifier of the pre-receive hook. |
Códigos de estado de respuesta HTTP para "Get a pre-receive hook"
status code | Descripción |
---|---|
200 | OK |
Ejemplos de código para "Get a pre-receive hook"
Ejemplo de solicitud
curl -L \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>" \
http(s)://HOSTNAME/api/v3/admin/pre-receive-hooks/PRE_RECEIVE_HOOK_ID
Response
Status: 200
{
"id": 1,
"name": "Check Commits",
"enforcement": "disabled",
"script": "scripts/commmit_check.sh",
"script_repository": {
"id": 595,
"full_name": "DevIT/hooks",
"url": "https://github.example.com/api/v3/repos/DevIT/hooks",
"html_url": "https://github.example.com/DevIT/hooks"
},
"environment": {
"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
}
},
"allow_downstream_configuration": false
}
Update a pre-receive hook
Parámetros para "Update a pre-receive hook"
Nombre, Tipo, Descripción |
---|
accept string Setting to |
Nombre, Tipo, Descripción |
---|
pre_receive_hook_id integer RequeridoThe unique identifier of the pre-receive hook. |
Nombre, Tipo, Descripción |
---|
name string The name of the hook. |
script string The script that the hook runs. |
script_repository object The GitHub repository where the script is kept. |
environment object The pre-receive environment where the script is executed. |
enforcement string The state of enforcement for this hook. |
allow_downstream_configuration boolean Whether enforcement can be overridden at the org or repo level. |
Códigos de estado de respuesta HTTP para "Update a pre-receive hook"
status code | Descripción |
---|---|
200 | OK |
Ejemplos de código para "Update a pre-receive hook"
Ejemplo de solicitud
curl -L \
-X PATCH \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>" \
http(s)://HOSTNAME/api/v3/admin/pre-receive-hooks/PRE_RECEIVE_HOOK_ID \
-d '{"name":"Check Commits","environment":{"id":1},"allow_downstream_configuration":true}'
Response
Status: 200
{
"id": 1,
"name": "Check Commits",
"enforcement": "disabled",
"script": "scripts/commmit_check.sh",
"script_repository": {
"id": 595,
"full_name": "DevIT/hooks",
"url": "https://github.example.com/api/v3/repos/DevIT/hooks",
"html_url": "https://github.example.com/DevIT/hooks"
},
"environment": {
"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": 1,
"download": {
"url": "https://github.example.com/api/v3/admin/pre-receive-environments/1/downloads/latest",
"state": "success",
"downloaded_at": "2016-05-26T07:42:53-05:00",
"message": null
}
},
"allow_downstream_configuration": true
}
Delete a pre-receive hook
Parámetros para "Delete a pre-receive hook"
Nombre, Tipo, Descripción |
---|
accept string Setting to |
Nombre, Tipo, Descripción |
---|
pre_receive_hook_id integer RequeridoThe unique identifier of the pre-receive hook. |
Códigos de estado de respuesta HTTP para "Delete a pre-receive hook"
status code | Descripción |
---|---|
204 | No Content |
Ejemplos de código para "Delete a pre-receive hook"
Ejemplo de solicitud
curl -L \
-X DELETE \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>" \
http(s)://HOSTNAME/api/v3/admin/pre-receive-hooks/PRE_RECEIVE_HOOK_ID
Response
Status: 204