Esta versão do GitHub Enterprise foi descontinuada em 2022-06-03. Nenhum lançamento de patch será feito, mesmo para questões críticas de segurança. Para obter melhor desempenho, melhorar a segurança e novos recursos, upgrade to the latest version of GitHub Enterprise. Para ajuda com a atualização, contact GitHub Enterprise support.
We've recently moved some of the REST API documentation. If you can't find what you're looking for, you might try the Actions REST API page.
Hooks pre-receive do repositório
A API de hooks pre-receive do Repositório permite que você veja e modifique a aplicação dos hooks de pre-receive que estão disponíveis em um repositório.
Atributos do objeto
| Nome | Tipo | Descrição |
|---|---|---|
name | string | O nome do hook. |
enforcement | string | O estado de aplicação para o hook neste repositório. |
configuration_url | string | URL para o ponto de extremidade em que a aplicação é definida. |
Os valores possíveis para aplicação são habilitado, desabilitado etestando. desabilitado indica que o hook pre-receive não será executado. habilitado indica que será executado e rejeitará quaisquer pushes que resultem em um estado diferente de zero. testando significa que o script será executado, mas não fará com que quaisquer pushes sejam rejeitados.
configuration_url pode ser um link para este repositório, seu proprietário da organização ou configuração global. A autorização para acessar o ponto de extremidade no configuration_url é determinada no nível de proprietário ou administrador do site.
List pre-receive hooks for a repository
List all pre-receive hooks that are enabled or testing for this repository as well as any disabled hooks that are allowed to be enabled at the repository level. Pre-receive hooks that are disabled at a higher level and are not configurable will not be listed.
Parâmetros
| Headers |
|---|
| Nome, Tipo, Descrição |
acceptstringSetting to |
| Path parameters |
| Nome, Tipo, Descrição |
ownerstringObrigatórioThe account owner of the repository. The name is not case sensitive. |
repostringObrigatórioThe name of the repository. The name is not case sensitive. |
| Parâmetros de consulta |
| Nome, Tipo, Descrição |
per_pageintegerThe number of results per page (max 100). Padrão: |
pageintegerPage number of the results to fetch. Padrão: |
directionstringThe direction to sort the results by. Padrão: Pode ser uma das ações a seguir: |
sortstringPadrão: Pode ser uma das ações a seguir: |
HTTP response status codes
| Status code | Descrição |
|---|---|
200 | OK |
Amostras de código
curl \
-H "Accept: application/vnd.github.v3+json" \
-H "Authorization: token <TOKEN>" \
http(s)://HOSTNAME/api/v3/repos/OWNER/REPO/pre-receive-hooksResponse
Status: 200[
{
"id": 42,
"name": "Check Commits",
"enforcement": "disabled",
"configuration_url": "https://github.example.com/api/v3/orgs/octocat/pre-receive-hooks/42"
}
]Aviso de pré-visualização
APIs for managing pre-receive hooks are currently available for developers to preview. During the preview period, the APIs may change without advance notice.
To access the API you must provide a custom media type in the Accept header:
application/vnd.github.eye-scream-previewGet a pre-receive hook for a repository
Parâmetros
| Headers |
|---|
| Nome, Tipo, Descrição |
acceptstringSetting to |
| Path parameters |
| Nome, Tipo, Descrição |
ownerstringObrigatórioThe account owner of the repository. The name is not case sensitive. |
repostringObrigatórioThe name of the repository. The name is not case sensitive. |
pre_receive_hook_idintegerObrigatórioThe unique identifier of the pre-receive hook. |
HTTP response status codes
| Status code | Descrição |
|---|---|
200 | OK |
Amostras de código
curl \
-H "Accept: application/vnd.github.v3+json" \
-H "Authorization: token <TOKEN>" \
http(s)://HOSTNAME/api/v3/repos/OWNER/REPO/pre-receive-hooks/PRE_RECEIVE_HOOK_IDResponse
Status: 200{
"id": 42,
"name": "Check Commits",
"enforcement": "disabled",
"configuration_url": "https://github.example.com/api/v3/orgs/octocat/pre-receive-hooks/42"
}Aviso de pré-visualização
APIs for managing pre-receive hooks are currently available for developers to preview. During the preview period, the APIs may change without advance notice.
To access the API you must provide a custom media type in the Accept header:
application/vnd.github.eye-scream-previewUpdate pre-receive hook enforcement for a repository
For pre-receive hooks which are allowed to be configured at the repo level, you can set enforcement
Parâmetros
| Headers |
|---|
| Nome, Tipo, Descrição |
acceptstringSetting to |
| Path parameters |
| Nome, Tipo, Descrição |
ownerstringObrigatórioThe account owner of the repository. The name is not case sensitive. |
repostringObrigatórioThe name of the repository. The name is not case sensitive. |
pre_receive_hook_idintegerObrigatórioThe unique identifier of the pre-receive hook. |
| Body parameters |
| Nome, Tipo, Descrição |
enforcementstringThe state of enforcement for the hook on this repository. Pode ser uma das ações a seguir: |
HTTP response status codes
| Status code | Descrição |
|---|---|
200 | OK |
Amostras de código
curl \
-X PATCH \
-H "Accept: application/vnd.github.v3+json" \
-H "Authorization: token <TOKEN>" \
http(s)://HOSTNAME/api/v3/repos/OWNER/REPO/pre-receive-hooks/PRE_RECEIVE_HOOK_ID \
-d '{"enforcement":"enabled"}'Response
Status: 200{
"id": 42,
"name": "Check Commits",
"enforcement": "enabled",
"configuration_url": "https://github.example.com/api/v3/repos/octocat/hello-world/pre-receive-hooks/42"
}Aviso de pré-visualização
APIs for managing pre-receive hooks are currently available for developers to preview. During the preview period, the APIs may change without advance notice.
To access the API you must provide a custom media type in the Accept header:
application/vnd.github.eye-scream-previewRemove pre-receive hook enforcement for a repository
Deletes any overridden enforcement on this repository for the specified hook.
Responds with effective values inherited from owner and/or global level.
Parâmetros
| Headers |
|---|
| Nome, Tipo, Descrição |
acceptstringSetting to |
| Path parameters |
| Nome, Tipo, Descrição |
ownerstringObrigatórioThe account owner of the repository. The name is not case sensitive. |
repostringObrigatórioThe name of the repository. The name is not case sensitive. |
pre_receive_hook_idintegerObrigatórioThe unique identifier of the pre-receive hook. |
HTTP response status codes
| Status code | Descrição |
|---|---|
200 | Responds with effective values inherited from owner and/or global level. |
Amostras de código
curl \
-X DELETE \
-H "Accept: application/vnd.github.v3+json" \
-H "Authorization: token <TOKEN>" \
http(s)://HOSTNAME/api/v3/repos/OWNER/REPO/pre-receive-hooks/PRE_RECEIVE_HOOK_IDResponds with effective values inherited from owner and/or global level.
Status: 200{
"id": 42,
"name": "Check Commits",
"enforcement": "disabled",
"configuration_url": "https://github.example.com/api/v3/orgs/octocat/pre-receive-hooks/42"
}Aviso de pré-visualização
APIs for managing pre-receive hooks are currently available for developers to preview. During the preview period, the APIs may change without advance notice.
To access the API you must provide a custom media type in the Accept header:
application/vnd.github.eye-scream-preview