Skip to main content
설명서에 자주 업데이트를 게시하며 이 페이지의 번역이 계속 진행 중일 수 있습니다. 최신 정보는 영어 설명서를 참조하세요.

최근에 REST API 설명서 중 일부를 이동했습니다. 원하는 항목을 찾을 수 없는 경우 동작 REST API 페이지를 사용해 볼 수 있습니다.

사전 수신 후크

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

사전 수신 후크 정보

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

개체 특성

사전 수신 후크

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

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

List pre-receive hooks

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

헤더
이름, 형식, Description
accept string

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

쿼리 매개 변수
이름, 형식, Description
per_page integer

The number of results per page (max 100).

기본값: 30

page integer

Page number of the results to fetch.

기본값: 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 응답 상태 코드

상태 코드Description
200

OK

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

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

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

헤더
이름, 형식, Description
accept string

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

본문 매개 변수
이름, 형식, Description
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. 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 응답 상태 코드

상태 코드Description
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>" \ 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"에 대한 매개 변수

헤더
이름, 형식, Description
accept string

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

경로 매개 변수
이름, 형식, Description
pre_receive_hook_id integer 필수

The unique identifier of the pre-receive hook.

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

상태 코드Description
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>" \ 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"에 대한 매개 변수

헤더
이름, 형식, Description
accept string

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

경로 매개 변수
이름, 형식, Description
pre_receive_hook_id integer 필수

The unique identifier of the pre-receive hook.

본문 매개 변수
이름, 형식, Description
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 응답 상태 코드

상태 코드Description
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>" \ 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"에 대한 매개 변수

헤더
이름, 형식, Description
accept string

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

경로 매개 변수
이름, 형식, Description
pre_receive_hook_id integer 필수

The unique identifier of the pre-receive hook.

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

상태 코드Description
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>" \ http(s)://HOSTNAME/api/v3/admin/pre-receive-hooks/PRE_RECEIVE_HOOK_ID

Response

Status: 204