Cette version de GitHub Enterprise Server n'est plus disponible depuis le 2025-06-19. Aucune publication de correctifs n’est effectuée, même pour les problèmes de sécurité critiques. Pour de meilleures performances, une sécurité améliorée et de nouvelles fonctionnalités, effectuez une mise à niveau vers la dernière version de GitHub Enterprise. Pour obtenir de l’aide sur la mise à niveau, contactez le support GitHub Enterprise.
Points de terminaison d’API REST pour les environnements de pré-réception
Utilisez l’API REST pour créer, répertorier, mettre à jour et supprimer des environnements pour les hooks de pré-réception.
À propos des environnements de pré-réception
Ces points de terminaison sont uniquement disponibles pour les administrateurs de site authentifiés. Les utilisateurs normaux recevront une réponse 404.
Remarque
Ces points de terminaison prennent uniquement en charge l’authentification à l’aide d’un personal access token (classic). Pour plus d’informations, consultez « Gestion de vos jetons d'accès personnels ».
Attributs d’objet
Environnement de pré-réception
| Nom | Type | Description |
|---|---|---|
name | string | Nom de l’environnement tel qu’affiché dans l’interface utilisateur. |
image_url | string | URL vers le tarball qui sera téléchargé et extrait. |
default_environment | boolean | Indique s’il s’agit de l’environnement par défaut fourni avec GitHub. |
download | object | État de téléchargement de cet environnement. |
hooks_count | integer | Nombre de hooks pré-réception qui utilisent cet environnement. |
Téléchargement de l’environnement de pré-réception
| Nom | Type | Description |
|---|---|---|
state | string | État du téléchargement le plus récent. |
downloaded_at | string | Heure à laquelle le téléchargement le plus récent a démarré. |
message | string | En cas d’échec, des messages d’erreur sont générés. |
Les valeurs possibles pour state sont not_started, in_progress, success et failed.
List pre-receive environments
Jetons d’accès affinés pour « List pre-receive environments »
Ce point de terminaison ne fonctionne pas avec les jetons d’accès utilisateur d’application GitHub, les jetons d’accès d’installation d’application GitHub ou les jetons d’accès personnels affinés.
Paramètres pour « List pre-receive environments »
| Nom, Type, Description |
|---|
accept string Setting to |
| Nom, Type, Description |
|---|
per_page integer The number of results per page (max 100). For more information, see "Using pagination in the REST API." Default: |
page integer The page number of the results to fetch. For more information, see "Using pagination in the REST API." Default: |
direction string The direction to sort the results by. Default: Peut être: |
sort string Default: Peut être: |
Codes d’état de la réponse HTTP pour « List pre-receive environments »
| Code d’état | Description |
|---|---|
200 | OK |
Exemples de code pour « List pre-receive environments »
Exemple de requête
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
Jetons d’accès affinés pour « Create a pre-receive environment »
Ce point de terminaison ne fonctionne pas avec les jetons d’accès utilisateur d’application GitHub, les jetons d’accès d’installation d’application GitHub ou les jetons d’accès personnels affinés.
Paramètres pour « Create a pre-receive environment »
| Nom, Type, Description |
|---|
accept string Setting to |
| Nom, Type, Description |
|---|
name string ObligatoireThe new pre-receive environment's name. |
image_url string ObligatoireURL from which to download a tarball of this environment. |
Codes d’état de la réponse HTTP pour « Create a pre-receive environment »
| Code d’état | Description |
|---|---|
201 | Created |
Exemples de code pour « Create a pre-receive environment »
Exemple de requête
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
Jetons d’accès affinés pour « Get a pre-receive environment »
Ce point de terminaison ne fonctionne pas avec les jetons d’accès utilisateur d’application GitHub, les jetons d’accès d’installation d’application GitHub ou les jetons d’accès personnels affinés.
Paramètres pour « Get a pre-receive environment »
| Nom, Type, Description |
|---|
accept string Setting to |
| Nom, Type, Description |
|---|
pre_receive_environment_id integer ObligatoireThe unique identifier of the pre-receive environment. |
Codes d’état de la réponse HTTP pour « Get a pre-receive environment »
| Code d’état | Description |
|---|---|
200 | OK |
Exemples de code pour « Get a pre-receive environment »
Exemple de requête
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.
Jetons d’accès affinés pour « Update a pre-receive environment »
Ce point de terminaison ne fonctionne pas avec les jetons d’accès utilisateur d’application GitHub, les jetons d’accès d’installation d’application GitHub ou les jetons d’accès personnels affinés.
Paramètres pour « Update a pre-receive environment »
| Nom, Type, Description |
|---|
accept string Setting to |
| Nom, Type, Description |
|---|
pre_receive_environment_id integer ObligatoireThe unique identifier of the pre-receive environment. |
| Nom, Type, Description |
|---|
name string This pre-receive environment's new name. |
image_url string URL from which to download a tarball of this environment. |
Codes d’état de la réponse HTTP pour « Update a pre-receive environment »
| Code d’état | Description |
|---|---|
200 | OK |
422 | Client Errors |
Exemples de code pour « Update a pre-receive environment »
Exemple de requête
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
Jetons d’accès affinés pour « Delete a pre-receive environment »
Ce point de terminaison ne fonctionne pas avec les jetons d’accès utilisateur d’application GitHub, les jetons d’accès d’installation d’application GitHub ou les jetons d’accès personnels affinés.
Paramètres pour « Delete a pre-receive environment »
| Nom, Type, Description |
|---|
accept string Setting to |
| Nom, Type, Description |
|---|
pre_receive_environment_id integer ObligatoireThe unique identifier of the pre-receive environment. |
Codes d’état de la réponse HTTP pour « Delete a pre-receive environment »
| Code d’état | Description |
|---|---|
204 | No Content |
422 | Client Errors |
Exemples de code pour « Delete a pre-receive environment »
Exemple de requête
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
Jetons d’accès affinés pour « Start a pre-receive environment download »
Ce point de terminaison ne fonctionne pas avec les jetons d’accès utilisateur d’application GitHub, les jetons d’accès d’installation d’application GitHub ou les jetons d’accès personnels affinés.
Paramètres pour « Start a pre-receive environment download »
| Nom, Type, Description |
|---|
accept string Setting to |
| Nom, Type, Description |
|---|
pre_receive_environment_id integer ObligatoireThe unique identifier of the pre-receive environment. |
Codes d’état de la réponse HTTP pour « Start a pre-receive environment download »
| Code d’état | Description |
|---|---|
202 | Accepted |
422 | Client Errors |
Exemples de code pour « Start a pre-receive environment download »
Exemple de requête
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.
Jetons d’accès affinés pour « Get the download status for a pre-receive environment »
Ce point de terminaison ne fonctionne pas avec les jetons d’accès utilisateur d’application GitHub, les jetons d’accès d’installation d’application GitHub ou les jetons d’accès personnels affinés.
Paramètres pour « Get the download status for a pre-receive environment »
| Nom, Type, Description |
|---|
accept string Setting to |
| Nom, Type, Description |
|---|
pre_receive_environment_id integer ObligatoireThe unique identifier of the pre-receive environment. |
Codes d’état de la réponse HTTP pour « Get the download status for a pre-receive environment »
| Code d’état | Description |
|---|---|
200 | OK |
Exemples de code pour « Get the download status for a pre-receive environment »
Exemple de requête
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
}