Эта версия GitHub Enterprise Server была прекращена 2024-09-25. Исправления выпускаться не будут даже при критических проблемах безопасности. Для повышения производительности, повышения безопасности и новых функций выполните обновление до последней версии GitHub Enterprise Server. Чтобы получить справку по обновлению, обратитесь в службу поддержки GitHub Enterprise.
Конечные точки REST API для перехватчики предварительного получения
Используйте REST API для создания, перечисления, обновления и удаления перехватчики предварительного получения.
Сведения о перехватчиках предварительного получения
Эти конечные точки доступны только администраторам сайта, прошедшим проверку подлинности. Обычные 404 пользователи получат ответ.
Note
Эти конечные точки поддерживают проверку подлинности только с помощью personal access token (classic). Дополнительные сведения см. в разделе Управление личными маркерами доступа.
Атрибуты объектов
Перехватчик предварительного получения
| Имя. | Тип | Описание | 
|---|---|---|
name | string | Имя перехватчика. | 
script | string | Скрипт, выполняемый перехватчиком. | 
script_repository | object | Репозиторий GitHub, в котором хранится скрипт. | 
environment | object | Среда предварительного получения, в которой выполняется скрипт. | 
enforcement | string | Состояние принудительного применения этого перехватчика. | 
allow_downstream_configuration | boolean | Возможность переопределения принудительного применения на уровне организации или репозитория. | 
Возможные значения для принудительного применения: enabled, disabled и testing. disabled указывает, что перехватчик предварительного получения не будет выполняться. enabled указывает, что он будет выполняться и отклонять все отправки, результатом которых является переход в ненулевое состояние. testing означает, что скрипт будет выполняться, но отправки отклоняться не будут.
List pre-receive hooks
Подробные маркеры доступа для "List pre-receive hooks
Эта конечная точка не работает с маркерами доступа пользователей приложения GitHub, маркерами доступа к установке приложения GitHub или точными личными маркерами доступа.
Параметры для "List pre-receive hooks"
| Имя., Тип, Description | 
|---|
accept string Setting to   | 
| Имя., Тип, Description | 
|---|
per_page integer The number of results per page (max 100). For more information, see "Using pagination in the REST API." По умолчанию.:   | 
page integer The page number of the results to fetch. For more information, see "Using pagination in the REST API." По умолчанию.:   | 
direction string The direction to sort the results by. По умолчанию.:  Возможные значения:   | 
sort string The property to sort the results by. По умолчанию.:  Возможные значения:   | 
Коды состояния http-ответа для "List pre-receive hooks"
| Код состояния | Описание | 
|---|---|
200 | OK  | 
Примеры кода для "List 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-hooksResponse
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"
| Имя., Тип, Description | 
|---|
accept string Setting to   | 
| Имя., Тип, 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:   | 
allow_downstream_configuration boolean Whether enforcement can be overridden at the org or repo level. default:   | 
Коды состояния http-ответа для "Create a pre-receive hook"
| Код состояния | Описание | 
|---|---|
201 | Created  | 
Примеры кода для "Create a pre-receive hook"
Пример запроса
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"
| Имя., Тип, Description | 
|---|
accept string Setting to   | 
| Имя., Тип, Description | 
|---|
pre_receive_hook_id integer Обязательное полеThe unique identifier of the pre-receive hook.  | 
Коды состояния http-ответа для "Get a pre-receive hook"
| Код состояния | Описание | 
|---|---|
200 | OK  | 
Примеры кода для "Get a pre-receive hook"
Пример запроса
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_IDResponse
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"
| Имя., Тип, Description | 
|---|
accept string Setting to   | 
| Имя., Тип, 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.  | 
Коды состояния http-ответа для "Update a pre-receive hook"
| Код состояния | Описание | 
|---|---|
200 | OK  | 
Примеры кода для "Update a pre-receive hook"
Пример запроса
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"
| Имя., Тип, Description | 
|---|
accept string Setting to   | 
| Имя., Тип, Description | 
|---|
pre_receive_hook_id integer Обязательное полеThe unique identifier of the pre-receive hook.  | 
Коды состояния http-ответа для "Delete a pre-receive hook"
| Код состояния | Описание | 
|---|---|
204 | No Content  | 
Примеры кода для "Delete a pre-receive hook"
Пример запроса
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_IDResponse
Status: 204