Cette version de GitHub Enterprise Server n'est plus disponible depuis le 2024-03-26. Aucune publication de correctifs n’est effectuée, même pour les problèmes de sécurité critiques. Pour de meilleures performances, une sécurité améliorée et de nouvelles fonctionnalités, effectuez une mise à niveau vers la dernière version de GitHub Enterprise. Pour obtenir de l’aide sur la mise à niveau, contactez le support GitHub Enterprise.
Points de terminaison d’API REST pour les stratégies de branche de déploiement
Utilisez l’API REST pour gérer les stratégies de branche de déploiement personnalisées.
À propos des stratégies de branche de déploiement
Vous pouvez utiliser l’API REST pour spécifier des modèles de noms personnalisés auxquels les branches doivent correspondre afin de les déployer dans un environnement. La propriété deployment_branch_policy.custom_branch_policies
de l’environnement doit être définie sur true
pour utiliser ces points de terminaison. Pour mettre à jour le deployment_branch_policy
pour un environnement, consultez « Points de terminaison d’API REST pour les environnements de déploiement ».
Pour plus d’informations sur la restriction des déploiements d’environnement pour certaines branches, consultez « Utilisation d’environnements pour le déploiement ».
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.
Paramètres pour « List deployment branch policies »
Nom, Type, Description |
---|
accept string Setting to |
Nom, Type, Description |
---|
owner string ObligatoireThe account owner of the repository. The name is not case sensitive. |
repo string ObligatoireThe name of the repository without the |
environment_name string ObligatoireThe name of the environment. The name must be URL encoded. For example, any slashes in the name must be replaced with |
Nom, Type, Description |
---|
per_page integer The number of results per page (max 100). For more information, see "Using pagination in the REST API." Default: |
page integer The page number of the results to fetch. For more information, see "Using pagination in the REST API." Default: |
Codes d’état de la réponse HTTP pour « List deployment branch policies »
Code d’état | Description |
---|---|
200 | OK |
Exemples de code pour « List deployment branch policies »
Exemple de requête
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.
Paramètres pour « Create a deployment branch policy »
Nom, Type, Description |
---|
accept string Setting to |
Nom, Type, Description |
---|
owner string ObligatoireThe account owner of the repository. The name is not case sensitive. |
repo string ObligatoireThe name of the repository without the |
environment_name string ObligatoireThe name of the environment. The name must be URL encoded. For example, any slashes in the name must be replaced with |
Nom, Type, Description |
---|
name string ObligatoireThe name pattern that branches or tags must match in order to deploy to the environment. Wildcard characters will not match |
Codes d’état de la réponse HTTP pour « Create a deployment branch policy »
Code d’état | Description |
---|---|
200 | OK |
303 | Response if the same branch name pattern already exists |
404 | Not Found or |
Exemples de code pour « Create a deployment branch policy »
Exemples de requête
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.
Paramètres pour « Get a deployment branch policy »
Nom, Type, Description |
---|
accept string Setting to |
Nom, Type, Description |
---|
owner string ObligatoireThe account owner of the repository. The name is not case sensitive. |
repo string ObligatoireThe name of the repository without the |
environment_name string ObligatoireThe 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 ObligatoireThe unique identifier of the branch policy. |
Codes d’état de la réponse HTTP pour « Get a deployment branch policy »
Code d’état | Description |
---|---|
200 | OK |
Exemples de code pour « Get a deployment branch policy »
Exemple de requête
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.
Paramètres pour « Update a deployment branch policy »
Nom, Type, Description |
---|
accept string Setting to |
Nom, Type, Description |
---|
owner string ObligatoireThe account owner of the repository. The name is not case sensitive. |
repo string ObligatoireThe name of the repository without the |
environment_name string ObligatoireThe 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 ObligatoireThe unique identifier of the branch policy. |
Nom, Type, Description |
---|
name string ObligatoireThe name pattern that branches must match in order to deploy to the environment. Wildcard characters will not match |
Codes d’état de la réponse HTTP pour « Update a deployment branch policy »
Code d’état | Description |
---|---|
200 | OK |
Exemples de code pour « Update a deployment branch policy »
Exemple de requête
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.
Paramètres pour « Delete a deployment branch policy »
Nom, Type, Description |
---|
accept string Setting to |
Nom, Type, Description |
---|
owner string ObligatoireThe account owner of the repository. The name is not case sensitive. |
repo string ObligatoireThe name of the repository without the |
environment_name string ObligatoireThe 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 ObligatoireThe unique identifier of the branch policy. |
Codes d’état de la réponse HTTP pour « Delete a deployment branch policy »
Code d’état | Description |
---|---|
204 | No Content |
Exemples de code pour « Delete a deployment branch policy »
Exemple de requête
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