Create a pre-receive hook
POST /admin/pre-receive-hooks
Parameters
| Name |
Type |
Description |
name |
string |
Required. The name of the hook. |
script |
string |
Required. The script that the hook runs. |
script_repository |
object |
Required. The GitHub repository where the script is kept. |
environment |
object |
Required. The pre-receive environment where the script is executed. |
enforcement |
string |
The state of enforcement for this hook. default: disabled
|
allow_downstream_configuration |
boolean |
Whether enforcement can be overridden at the org or repo level. default: false
|
{
"name": "Check Commits",
"script": "scripts/commit_check.sh",
"enforcement": "disabled",
"allow_downstream_configuration": false,
"script_repository": {
"full_name": "DevIT/hooks"
},
"environment": {
"id": 2
}
}
Response
{
"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
}