Skip to main content
이제 REST API의 버전이 지정되었습니다. 자세한 내용은 "API 버전 관리 정보"를 참조하세요.

사전 수신 후크에 대한 REST API 엔드포인트

REST API를 사용하면 사전 수신 후크를 만들고, 나열하고, 업데이트하고, 삭제할 수 있습니다.

사전 수신 후크 정보

이러한 엔드포인트는 인증된 사이트 관리자만 사용할 수 있습니다. 일반 사용자는 404 응답을 받게 됩니다.

이러한 엔드포인트는 personal access token (classic)을(를) 사용하는 인증만 지원합니다. 자세한 내용은 "개인용 액세스 토큰 관리"을 참조하세요.

개체 특성

사전 수신 후크

이름형식설명
namestring후크의 이름입니다.
scriptstring후크가 실행하는 스크립트입니다.
script_repositoryobject스크립트가 보관된 GitHub 리포지토리입니다.
environmentobject스크립트가 실행되는 사전 수신 환경입니다.
enforcementstring이 후크의 적용 상태입니다.
allow_downstream_configurationboolean조직 또는 리포지토리 수준에서 적용을 재정의할 수 있는지 여부입니다.

적용 가능한 값은 enabled, disabled, testing입니다.__ disabled는 사전 수신 후크가 실행되지 않음을 나타냅니다. enabled는 0이 아닌 상태가 되는 모든 푸시를 실행하고 거부함을 나타냅니다. testing은 스크립트가 실행되지만 푸시가 거부되지 않음을 의미합니다.

List pre-receive hooks

"List pre-receive hooks"에 대한 세분화된 액세스 토큰

이 엔드포인트는 GitHub 앱 사용자 액세스 토큰, GitHub 앱 설치 액세스 토큰 또는 세분화된 개인용 액세스 토큰에서 작동하지 않습니다.

"List pre-receive hooks"에 대한 매개 변수

헤더
이름, Type, 설명
accept string

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

쿼리 매개 변수
이름, Type, 설명
per_page integer

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

기본값: 30

page integer

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

기본값: 1

direction string

The direction to sort the results by.

기본값: desc

다음 중 하나일 수 있습니다.: asc, desc

sort string

The property to sort the results by.

기본값: created

다음 중 하나일 수 있습니다.: created, updated, name

"List pre-receive hooks"에 대한 HTTP 응답 상태 코드

상태 코드설명
200

OK

"List pre-receive hooks"에 대한 코드 샘플

요청 예제

get/admin/pre-receive-hooks
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-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

"Create a pre-receive hook"에 대한 세분화된 액세스 토큰

이 엔드포인트는 GitHub 앱 사용자 액세스 토큰, GitHub 앱 설치 액세스 토큰 또는 세분화된 개인용 액세스 토큰에서 작동하지 않습니다.

"Create a pre-receive hook"에 대한 매개 변수

헤더
이름, Type, 설명
accept string

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

본문 매개 변수
이름, Type, 설명
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

"Create a pre-receive hook"에 대한 HTTP 응답 상태 코드

상태 코드설명
201

Created

"Create a pre-receive hook"에 대한 코드 샘플

요청 예제

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

"Get a pre-receive hook"에 대한 세분화된 액세스 토큰

이 엔드포인트는 GitHub 앱 사용자 액세스 토큰, GitHub 앱 설치 액세스 토큰 또는 세분화된 개인용 액세스 토큰에서 작동하지 않습니다.

"Get a pre-receive hook"에 대한 매개 변수

헤더
이름, Type, 설명
accept string

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

경로 매개 변수
이름, Type, 설명
pre_receive_hook_id integer Required

The unique identifier of the pre-receive hook.

"Get a pre-receive hook"에 대한 HTTP 응답 상태 코드

상태 코드설명
200

OK

"Get a pre-receive hook"에 대한 코드 샘플

요청 예제

get/admin/pre-receive-hooks/{pre_receive_hook_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-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

"Update a pre-receive hook"에 대한 세분화된 액세스 토큰

이 엔드포인트는 GitHub 앱 사용자 액세스 토큰, GitHub 앱 설치 액세스 토큰 또는 세분화된 개인용 액세스 토큰에서 작동하지 않습니다.

"Update a pre-receive hook"에 대한 매개 변수

헤더
이름, Type, 설명
accept string

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

경로 매개 변수
이름, Type, 설명
pre_receive_hook_id integer Required

The unique identifier of the pre-receive hook.

본문 매개 변수
이름, Type, 설명
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.

"Update a pre-receive hook"에 대한 HTTP 응답 상태 코드

상태 코드설명
200

OK

"Update a pre-receive hook"에 대한 코드 샘플

요청 예제

patch/admin/pre-receive-hooks/{pre_receive_hook_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-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

"Delete a pre-receive hook"에 대한 세분화된 액세스 토큰

이 엔드포인트는 GitHub 앱 사용자 액세스 토큰, GitHub 앱 설치 액세스 토큰 또는 세분화된 개인용 액세스 토큰에서 작동하지 않습니다.

"Delete a pre-receive hook"에 대한 매개 변수

헤더
이름, Type, 설명
accept string

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

경로 매개 변수
이름, Type, 설명
pre_receive_hook_id integer Required

The unique identifier of the pre-receive hook.

"Delete a pre-receive hook"에 대한 HTTP 응답 상태 코드

상태 코드설명
204

No Content

"Delete a pre-receive hook"에 대한 코드 샘플

요청 예제

delete/admin/pre-receive-hooks/{pre_receive_hook_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-hooks/PRE_RECEIVE_HOOK_ID

Response

Status: 204