Skip to main content

Diese Version von GitHub Enterprise Server wird eingestellt am 2026-08-25. Nicht mehr unterstützte Versionen werden nicht unterstützt. Es wird keine Patch-Freigabe vorgenommen, auch nicht für kritische Sicherheitsprobleme. Eine bessere Leistung, verbesserte Sicherheit und neue Features in GitHub Enterprise Server finden Sie unter Overview des Upgradeprozesses. Wenden Sie sich bei Fragen zum Upgrade an den GitHub Enterprise Support.

Die REST-API ist jetzt versioniert. Weitere Informationen findest du unter Informationen zur API-Versionsverwaltung.

REST-API-Endpunkte für 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 Websiteadministrator*innen verfügbar. Normale Benutzer erhalten eine 404-Antwort.

Hinweis

Diese Endpunkte unterstützen nur die Authentifizierung über ein personal access token (classic). Weitere Informationen finden Sie unter Verwalten deiner persönlichen Zugriffstoken.

Objektattribute

Pre-Receive-Umgebung

NameTypBESCHREIBUNG
namestringDer Name der Umgebung, wie auf der Benutzeroberfläche angezeigt.
image_urlstringURL zum Tarball, der heruntergeladen und extrahiert wird.
default_environmentbooleanGibt an, ob dies die in GitHub enthaltene Standardumgebung ist.
downloadobjectDer Downloadstatus dieser Umgebung.
hooks_countintegerDie Anzahl der Pre-Receive-Hooks, die diese Umgebung verwenden.

Download der Pre-Receive-Umgebung

NameTypBESCHREIBUNG
statestringDer Status des letzten Downloads.
downloaded_atstringDie Uhrzeit des Starts des letzten Downloads.
messagestringBei Fehlschlagen werden alle Fehlermeldungen ausgegeben.

Mögliche Werte für state sind not_started, in_progress``success, failed.

List pre-receive environments

Feinkörnige Zugriffstoken für "List pre-receive environments"

Dieser Endpunkt funktioniert nicht mit GitHub App-Benutzerzugriffstoken, GitHub App-Installationszugriffstoken oder fein abgestimmten persönlichen Zugriffstoken.

Parameter für "List pre-receive environments"

Header
Name, Typ, BESCHREIBUNG
accept string

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

Abfrageparameter
Name, Typ, BESCHREIBUNG
per_page integer

The number of results per page (max 100). For more information, see "Using pagination in the REST API."

Standard: 30

page integer

The page number of the results to fetch. For more information, see "Using pagination in the REST API."

Standard: 1

direction string

The direction to sort the results by.

Standard: desc

Kann eine der folgenden sein: asc, desc

sort string

Standard: created

Kann eine der folgenden sein: created, updated, name

HTTP-Antwortstatuscodes für "List pre-receive environments"

StatuscodeBESCHREIBUNG
200

OK

Codebeispiele für "List pre-receive environments"

Anforderungsbeispiel

get/admin/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-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 } } ]

Create a pre-receive environment

Feinkörnige Zugriffstoken für "Create a pre-receive environment"

Dieser Endpunkt funktioniert nicht mit GitHub App-Benutzerzugriffstoken, GitHub App-Installationszugriffstoken oder fein abgestimmten persönlichen Zugriffstoken.

Parameter für "Create a pre-receive environment"

Header
Name, Typ, BESCHREIBUNG
accept string

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

Körperparameter
Name, Typ, BESCHREIBUNG
name string Erforderlich

The new pre-receive environment's name.

image_url string Erforderlich

URL from which to download a tarball of this environment.

HTTP-Antwortstatuscodes für "Create a pre-receive environment"

StatuscodeBESCHREIBUNG
201

Created

Codebeispiele für "Create a pre-receive environment"

Anforderungsbeispiel

post/admin/pre-receive-environments
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

Feinkörnige Zugriffstoken für "Get a pre-receive environment"

Dieser Endpunkt funktioniert nicht mit GitHub App-Benutzerzugriffstoken, GitHub App-Installationszugriffstoken oder fein abgestimmten persönlichen Zugriffstoken.

Parameter für "Get a pre-receive environment"

Header
Name, Typ, BESCHREIBUNG
accept string

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

Pfadparameter
Name, Typ, BESCHREIBUNG
pre_receive_environment_id integer Erforderlich

The unique identifier of the pre-receive environment.

HTTP-Antwortstatuscodes für "Get a pre-receive environment"

StatuscodeBESCHREIBUNG
200

OK

Codebeispiele für "Get a pre-receive environment"

Anforderungsbeispiel

get/admin/pre-receive-environments/{pre_receive_environment_id}
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

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

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.

Feinkörnige Zugriffstoken für "Update a pre-receive environment"

Dieser Endpunkt funktioniert nicht mit GitHub App-Benutzerzugriffstoken, GitHub App-Installationszugriffstoken oder fein abgestimmten persönlichen Zugriffstoken.

Parameter für "Update a pre-receive environment"

Header
Name, Typ, BESCHREIBUNG
accept string

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

Pfadparameter
Name, Typ, BESCHREIBUNG
pre_receive_environment_id integer Erforderlich

The unique identifier of the pre-receive environment.

Körperparameter
Name, Typ, BESCHREIBUNG
name string

This pre-receive environment's new name.

image_url string

URL from which to download a tarball of this environment.

HTTP-Antwortstatuscodes für "Update a pre-receive environment"

StatuscodeBESCHREIBUNG
200

OK

422

Client Errors

Codebeispiele für "Update a pre-receive environment"

Anforderungsbeispiel

patch/admin/pre-receive-environments/{pre_receive_environment_id}
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

Feinkörnige Zugriffstoken für "Delete a pre-receive environment"

Dieser Endpunkt funktioniert nicht mit GitHub App-Benutzerzugriffstoken, GitHub App-Installationszugriffstoken oder fein abgestimmten persönlichen Zugriffstoken.

Parameter für "Delete a pre-receive environment"

Header
Name, Typ, BESCHREIBUNG
accept string

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

Pfadparameter
Name, Typ, BESCHREIBUNG
pre_receive_environment_id integer Erforderlich

The unique identifier of the pre-receive environment.

HTTP-Antwortstatuscodes für "Delete a pre-receive environment"

StatuscodeBESCHREIBUNG
204

No Content

422

Client Errors

Codebeispiele für "Delete a pre-receive environment"

Anforderungsbeispiel

delete/admin/pre-receive-environments/{pre_receive_environment_id}
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_ID

Response

Status: 204

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

Feinkörnige Zugriffstoken für "Start a pre-receive environment download"

Dieser Endpunkt funktioniert nicht mit GitHub App-Benutzerzugriffstoken, GitHub App-Installationszugriffstoken oder fein abgestimmten persönlichen Zugriffstoken.

Parameter für "Start a pre-receive environment download"

Header
Name, Typ, BESCHREIBUNG
accept string

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

Pfadparameter
Name, Typ, BESCHREIBUNG
pre_receive_environment_id integer Erforderlich

The unique identifier of the pre-receive environment.

HTTP-Antwortstatuscodes für "Start a pre-receive environment download"

StatuscodeBESCHREIBUNG
202

Accepted

422

Client Errors

Codebeispiele für "Start a pre-receive environment download"

Anforderungsbeispiel

post/admin/pre-receive-environments/{pre_receive_environment_id}/downloads
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/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 }

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.

Feinkörnige Zugriffstoken für "Get the download status for a pre-receive environment"

Dieser Endpunkt funktioniert nicht mit GitHub App-Benutzerzugriffstoken, GitHub App-Installationszugriffstoken oder fein abgestimmten persönlichen Zugriffstoken.

Parameter für "Get the download status for a pre-receive environment"

Header
Name, Typ, BESCHREIBUNG
accept string

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

Pfadparameter
Name, Typ, BESCHREIBUNG
pre_receive_environment_id integer Erforderlich

The unique identifier of the pre-receive environment.

HTTP-Antwortstatuscodes für "Get the download status for a pre-receive environment"

StatuscodeBESCHREIBUNG
200

OK

Codebeispiele für "Get the download status for a pre-receive environment"

Anforderungsbeispiel

get/admin/pre-receive-environments/{pre_receive_environment_id}/downloads/latest
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/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 }