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-Umgebungen
Verwende die REST-API, um Umgebungen für Pre-Receive-Hooks zu erstellen, aufzulisten, zu aktualisieren und zu löschen.
Informationen zu Pre-Receive-Umgebungen
Diese Endpunkte sind nur für authentifizierte Websiteadministratoren verfügbar. Normale Benutzer erhalten eine 404-Antwort.
Objektattribute
Pre-Receive-Umgebung
| Name | type | BESCHREIBUNG |
|---|---|---|
name | string | Der Name der Umgebung, wie auf der Benutzeroberfläche angezeigt. |
image_url | string | URL zum Tarball, der heruntergeladen und extrahiert wird. |
default_environment | boolean | Gibt an, ob dies die Standardumgebung im Lieferumfang von GitHub AE ist. |
download | object | Der Downloadstatus dieser Umgebung. |
hooks_count | integer | Die Anzahl der Pre-Receive-Hooks, die diese Umgebung verwenden. |
Download der Pre-Receive-Umgebung
| Name | type | BESCHREIBUNG |
|---|---|---|
state | string | Der Status des letzten Downloads. |
downloaded_at | string | Die Uhrzeit des Starts des letzten Downloads. |
message | string | Bei Fehlschlagen werden alle Fehlermeldungen ausgegeben. |
Mögliche Werte für state sind not_started, in_progress success, failed.
List pre-receive environments
Parameters for "List pre-receive environments"
| Headers |
|---|
| Name, Type, Description |
acceptstringSetting to |
| Query parameters |
| Name, Type, Description |
per_pageintegerThe number of results per page (max 100). Default: |
pageintegerPage number of the results to fetch. Default: |
directionstringThe direction to sort the results by. Default: Can be one of: |
sortstringDefault: Can be one of: |
HTTP response status codes for "List pre-receive environments"
| Status code | Description |
|---|---|
200 | OK |
Code samples for "List pre-receive environments"
curl -L \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>" \
https://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
Parameters for "Create a pre-receive environment"
| Headers |
|---|
| Name, Type, Description |
acceptstringSetting to |
| Body parameters |
| Name, Type, Description |
namestringRequiredThe new pre-receive environment's name. |
image_urlstringRequiredURL from which to download a tarball of this environment. |
HTTP response status codes for "Create a pre-receive environment"
| Status code | Description |
|---|---|
201 | Created |
Code samples for "Create a pre-receive environment"
curl -L \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>" \
https://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
Parameters for "Get a pre-receive environment"
| Headers |
|---|
| Name, Type, Description |
acceptstringSetting to |
| Path parameters |
| Name, Type, Description |
pre_receive_environment_idintegerRequiredThe unique identifier of the pre-receive environment. |
HTTP response status codes for "Get a pre-receive environment"
| Status code | Description |
|---|---|
200 | OK |
Code samples for "Get a pre-receive environment"
curl -L \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>" \
https://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.
Parameters for "Update a pre-receive environment"
| Headers |
|---|
| Name, Type, Description |
acceptstringSetting to |
| Path parameters |
| Name, Type, Description |
pre_receive_environment_idintegerRequiredThe unique identifier of the pre-receive environment. |
| Body parameters |
| Name, Type, Description |
namestringThis pre-receive environment's new name. |
image_urlstringURL from which to download a tarball of this environment. |
HTTP response status codes for "Update a pre-receive environment"
| Status code | Description |
|---|---|
200 | OK |
422 | Client Errors |
Code samples for "Update a pre-receive environment"
curl -L \
-X PATCH \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>" \
https://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
Parameters for "Delete a pre-receive environment"
| Headers |
|---|
| Name, Type, Description |
acceptstringSetting to |
| Path parameters |
| Name, Type, Description |
pre_receive_environment_idintegerRequiredThe unique identifier of the pre-receive environment. |
HTTP response status codes for "Delete a pre-receive environment"
| Status code | Description |
|---|---|
204 | No Content |
422 | Client Errors |
Code samples for "Delete a pre-receive environment"
curl -L \
-X DELETE \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>" \
https://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
Parameters for "Start a pre-receive environment download"
| Headers |
|---|
| Name, Type, Description |
acceptstringSetting to |
| Path parameters |
| Name, Type, Description |
pre_receive_environment_idintegerRequiredThe unique identifier of the pre-receive environment. |
HTTP response status codes for "Start a pre-receive environment download"
| Status code | Description |
|---|---|
202 | Accepted |
422 | Client Errors |
Code samples for "Start a pre-receive environment download"
curl -L \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>" \
https://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.
Parameters for "Get the download status for a pre-receive environment"
| Headers |
|---|
| Name, Type, Description |
acceptstringSetting to |
| Path parameters |
| Name, Type, Description |
pre_receive_environment_idintegerRequiredThe unique identifier of the pre-receive environment. |
HTTP response status codes for "Get the download status for a pre-receive environment"
| Status code | Description |
|---|---|
200 | OK |
Code samples for "Get the download status for a pre-receive environment"
curl -L \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>" \
https://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
}