Diese Version von GitHub Enterprise Server wurde eingestellt am 2024-03-26. Es wird keine Patch-Freigabe vorgenommen, auch nicht für kritische Sicherheitsprobleme. Für bessere Leistung, verbesserte Sicherheit und neue Features aktualisiere auf die neueste Version von GitHub Enterprise Server. Wende dich an den GitHub Enterprise-Support, um Hilfe zum Upgrade zu erhalten.
REST-API-Endpunkte für Pre-Receive-Hooks
Verwende die REST-API, um Pre-Receive-Hooks zu erstellen, aufzulisten, zu aktualisieren und zu löschen.
Informationen zu Pre-Receive-Hooks
Diese Endpunkte sind nur für authentifizierte Websiteadministrator*innen verfügbar. Normale Benutzer erhalten eine 404
-Antwort.
Objektattribute
Pre-Receive-Hook
Name | Typ | BESCHREIBUNG |
---|---|---|
name | string | Der Name des Hooks. |
script | string | Das Skript, das der Hook ausführt |
script_repository | object | Das GitHub Repository, in dem das Skript aufbewahrt wird |
environment | object | Die vorab empfangene Umgebung, in der das Skript ausgeführt wird |
enforcement | string | Der Status der Erzwingung für diesen Hook |
allow_downstream_configuration | boolean | Information, ob die Erzwingung auf Organisations- oder Repositoryebene außer Kraft gesetzt werden kann |
Mögliche Werte für die Erzwingung sind enabled
, disabled
undtesting
. disabled
gibt an, dass der Pre-Receive-Hook nicht ausgeführt wird. enabled
gibt an, dass alle Pushs ausgeführt und abgelehnt werden, die zu einem anderen Status als null (0) führen. testing
bedeutet, dass das Skript zwar ausgeführt wird, aber keine Ablehnung von Pushs auslösen wird.
List pre-receive hooks
Parameter für „List pre-receive hooks“
Name, type, BESCHREIBUNG |
---|
accept string Setting to |
Name, type, BESCHREIBUNG |
---|
per_page integer The number of results per page (max 100). For more information, see "Using pagination in the REST API." Standard: |
page integer The page number of the results to fetch. For more information, see "Using pagination in the REST API." Standard: |
direction string The direction to sort the results by. Standard: Kann eine der Folgenden sein: |
sort string The property to sort the results by. Standard: Kann eine der Folgenden sein: |
HTTP-Antwortstatuscodes für „List pre-receive hooks“
Statuscode | BESCHREIBUNG |
---|---|
200 | OK |
Codebeispiele für „List pre-receive hooks“
Beispiel für eine Anfrage
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
Parameter für „Create a pre-receive hook“
Name, type, BESCHREIBUNG |
---|
accept string Setting to |
Name, type, BESCHREIBUNG |
---|
name string ErforderlichThe name of the hook. |
script string ErforderlichThe script that the hook runs. |
script_repository object ErforderlichThe GitHub repository where the script is kept. |
environment object ErforderlichThe 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: |
HTTP-Antwortstatuscodes für „Create a pre-receive hook“
Statuscode | BESCHREIBUNG |
---|---|
201 | Created |
Codebeispiele für „Create a pre-receive hook“
Beispiel für eine Anfrage
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
Parameter für „Get a pre-receive hook“
Name, type, BESCHREIBUNG |
---|
accept string Setting to |
Name, type, BESCHREIBUNG |
---|
pre_receive_hook_id integer ErforderlichThe unique identifier of the pre-receive hook. |
HTTP-Antwortstatuscodes für „Get a pre-receive hook“
Statuscode | BESCHREIBUNG |
---|---|
200 | OK |
Codebeispiele für „Get a pre-receive hook“
Beispiel für eine Anfrage
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
Parameter für „Update a pre-receive hook“
Name, type, BESCHREIBUNG |
---|
accept string Setting to |
Name, type, BESCHREIBUNG |
---|
pre_receive_hook_id integer ErforderlichThe unique identifier of the pre-receive hook. |
Name, type, BESCHREIBUNG |
---|
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. |
HTTP-Antwortstatuscodes für „Update a pre-receive hook“
Statuscode | BESCHREIBUNG |
---|---|
200 | OK |
Codebeispiele für „Update a pre-receive hook“
Beispiel für eine Anfrage
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
Parameter für „Delete a pre-receive hook“
Name, type, BESCHREIBUNG |
---|
accept string Setting to |
Name, type, BESCHREIBUNG |
---|
pre_receive_hook_id integer ErforderlichThe unique identifier of the pre-receive hook. |
HTTP-Antwortstatuscodes für „Delete a pre-receive hook“
Statuscode | BESCHREIBUNG |
---|---|
204 | No Content |
Codebeispiele für „Delete a pre-receive hook“
Beispiel für eine Anfrage
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