Esta versión de GitHub Enterprise Server se discontinuó el 2024-03-26. No se realizarán lanzamientos de patch, ni siquiera para problemas de seguridad críticos. Para obtener rendimiento mejorado, seguridad mejorada y nuevas características, actualice a la versión más reciente de GitHub Enterprise Server. Para obtener ayuda con la actualización, póngase en contacto con el soporte técnico de GitHub Enterprise.
Puntos de conexión de la API de REST para directivas de rama de implementación
Usa la API REST para administrar directivas de rama de implementación personalizadas.
Acerca de las directivas de rama de implementación
Puedes usar la API REST para especificar patrones de nombre personalizados que las ramas deben cumplir con el fin de implementarse en un entorno. La propiedad deployment_branch_policy.custom_branch_policies
del entorno debe establecerse en true
para usar estos puntos de conexión. Para actualizar deployment_branch_policy
para un entorno, consulta "Puntos de conexión de la API de REST para entornos de implementación".
Para más información sobre cómo restringir las implementaciones de entorno a determinadas ramas, consulta "Utilizar ambientes para el despliegue".
List deployment branch policies
Lists the deployment branch policies for an environment.
Anyone with read access to the repository can use this endpoint.
OAuth app tokens and personal access tokens (classic) need the repo
scope to use this endpoint with a private repository.
Parámetros para "List deployment branch policies"
Nombre, Tipo, Descripción |
---|
accept string Setting to |
Nombre, Tipo, Descripción |
---|
owner string RequeridoThe account owner of the repository. The name is not case sensitive. |
repo string RequeridoThe name of the repository without the |
environment_name string RequeridoThe name of the environment. The name must be URL encoded. For example, any slashes in the name must be replaced with |
Nombre, Tipo, Descripción |
---|
per_page integer The number of results per page (max 100). For more information, see "Using pagination in the REST API." Valor predeterminado: |
page integer The page number of the results to fetch. For more information, see "Using pagination in the REST API." Valor predeterminado: |
Códigos de estado de respuesta HTTP para "List deployment branch policies"
status code | Descripción |
---|---|
200 | OK |
Ejemplos de código para "List deployment branch policies"
Ejemplo de solicitud
curl -L \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>" \
http(s)://HOSTNAME/api/v3/repos/OWNER/REPO/environments/ENVIRONMENT_NAME/deployment-branch-policies
Response
Status: 200
{
"total_count": 2,
"branch_policies": [
{
"id": 361471,
"node_id": "MDE2OkdhdGVCcmFuY2hQb2xpY3kzNjE0NzE=",
"name": "release/*"
},
{
"id": 361472,
"node_id": "MDE2OkdhdGVCcmFuY2hQb2xpY3kzNjE0NzI=",
"name": "main"
}
]
}
Create a deployment branch policy
Creates a deployment branch policy for an environment.
OAuth app tokens and personal access tokens (classic) need the repo
scope to use this endpoint.
Parámetros para "Create a deployment branch policy"
Nombre, Tipo, Descripción |
---|
accept string Setting to |
Nombre, Tipo, Descripción |
---|
owner string RequeridoThe account owner of the repository. The name is not case sensitive. |
repo string RequeridoThe name of the repository without the |
environment_name string RequeridoThe name of the environment. The name must be URL encoded. For example, any slashes in the name must be replaced with |
Nombre, Tipo, Descripción |
---|
name string RequeridoThe name pattern that branches or tags must match in order to deploy to the environment. Wildcard characters will not match |
Códigos de estado de respuesta HTTP para "Create a deployment branch policy"
status code | Descripción |
---|---|
200 | OK |
303 | Response if the same branch name pattern already exists |
404 | Not Found or |
Ejemplos de código para "Create a deployment branch policy"
Ejemplos de solicitud
curl -L \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>" \
http(s)://HOSTNAME/api/v3/repos/OWNER/REPO/environments/ENVIRONMENT_NAME/deployment-branch-policies \
-d '{"name":"release/*"}'
Response
Status: 200
{
"id": 364662,
"node_id": "MDE2OkdhdGVCcmFuY2hQb2xpY3kzNjQ2NjI=",
"name": "release/*"
}
Get a deployment branch policy
Gets a deployment branch policy for an environment.
Anyone with read access to the repository can use this endpoint.
OAuth app tokens and personal access tokens (classic) need the repo
scope to use this endpoint with a private repository.
Parámetros para "Get a deployment branch policy"
Nombre, Tipo, Descripción |
---|
accept string Setting to |
Nombre, Tipo, Descripción |
---|
owner string RequeridoThe account owner of the repository. The name is not case sensitive. |
repo string RequeridoThe name of the repository without the |
environment_name string RequeridoThe name of the environment. The name must be URL encoded. For example, any slashes in the name must be replaced with |
branch_policy_id integer RequeridoThe unique identifier of the branch policy. |
Códigos de estado de respuesta HTTP para "Get a deployment branch policy"
status code | Descripción |
---|---|
200 | OK |
Ejemplos de código para "Get a deployment branch policy"
Ejemplo de solicitud
curl -L \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>" \
http(s)://HOSTNAME/api/v3/repos/OWNER/REPO/environments/ENVIRONMENT_NAME/deployment-branch-policies/BRANCH_POLICY_ID
Response
Status: 200
{
"id": 364662,
"node_id": "MDE2OkdhdGVCcmFuY2hQb2xpY3kzNjQ2NjI=",
"name": "release/*"
}
Update a deployment branch policy
Updates a deployment branch policy for an environment.
OAuth app tokens and personal access tokens (classic) need the repo
scope to use this endpoint.
Parámetros para "Update a deployment branch policy"
Nombre, Tipo, Descripción |
---|
accept string Setting to |
Nombre, Tipo, Descripción |
---|
owner string RequeridoThe account owner of the repository. The name is not case sensitive. |
repo string RequeridoThe name of the repository without the |
environment_name string RequeridoThe name of the environment. The name must be URL encoded. For example, any slashes in the name must be replaced with |
branch_policy_id integer RequeridoThe unique identifier of the branch policy. |
Nombre, Tipo, Descripción |
---|
name string RequeridoThe name pattern that branches must match in order to deploy to the environment. Wildcard characters will not match |
Códigos de estado de respuesta HTTP para "Update a deployment branch policy"
status code | Descripción |
---|---|
200 | OK |
Ejemplos de código para "Update a deployment branch policy"
Ejemplo de solicitud
curl -L \
-X PUT \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>" \
http(s)://HOSTNAME/api/v3/repos/OWNER/REPO/environments/ENVIRONMENT_NAME/deployment-branch-policies/BRANCH_POLICY_ID \
-d '{"name":"release/*"}'
Response
Status: 200
{
"id": 364662,
"node_id": "MDE2OkdhdGVCcmFuY2hQb2xpY3kzNjQ2NjI=",
"name": "release/*"
}
Delete a deployment branch policy
Deletes a deployment branch policy for an environment.
OAuth app tokens and personal access tokens (classic) need the repo
scope to use this endpoint.
Parámetros para "Delete a deployment branch policy"
Nombre, Tipo, Descripción |
---|
accept string Setting to |
Nombre, Tipo, Descripción |
---|
owner string RequeridoThe account owner of the repository. The name is not case sensitive. |
repo string RequeridoThe name of the repository without the |
environment_name string RequeridoThe name of the environment. The name must be URL encoded. For example, any slashes in the name must be replaced with |
branch_policy_id integer RequeridoThe unique identifier of the branch policy. |
Códigos de estado de respuesta HTTP para "Delete a deployment branch policy"
status code | Descripción |
---|---|
204 | No Content |
Ejemplos de código para "Delete a deployment branch policy"
Ejemplo de solicitud
curl -L \
-X DELETE \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>" \
http(s)://HOSTNAME/api/v3/repos/OWNER/REPO/environments/ENVIRONMENT_NAME/deployment-branch-policies/BRANCH_POLICY_ID
Response
Status: 204