Diese Version von GitHub Enterprise Server wurde eingestellt am 2024-03-26. Es wird keine Patch-Freigabe vorgenommen, auch nicht für kritische Sicherheitsprobleme. Für bessere Leistung, verbesserte Sicherheit und neue Features aktualisiere auf die neueste Version von GitHub Enterprise Server. Wende dich an den GitHub Enterprise-Support, um Hilfe zum Upgrade zu erhalten.
REST-API-Endpunkte für Richtlinien für Bereitstellungsbranches
Verwende die REST-API, um benutzerdefinierte Richtlinien für Bereitstellungsbranches zu verwalten.
Informationen zu Richtlinien für Bereitstellungsbranches
Du kannst die REST-API verwenden, um benutzerdefinierte Namensmuster anzugeben, mit denen Branches übereinstimmen müssen, damit die Bereitstellung in einer Umgebung funktioniert. Die deployment_branch_policy.custom_branch_policies
-Eigenschaft für die Umgebung muss auf true
festgelegt werden, um diese Endpunkte zu verwenden. Informationen zum Aktualisieren der deployment_branch_policy
für eine Umgebung findest du unter REST-API-Endpunkte für Bereitstellungsumgebungen.
Weitere Informationen zum Einschränken von Umgebungsbereitstellungen auf bestimmte Branches findest du unter Verwenden von Umgebungen für die Bereitstellung.
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.
Parameter für „List deployment branch policies“
Name, type, BESCHREIBUNG |
---|
accept string Setting to |
Name, type, BESCHREIBUNG |
---|
owner string ErforderlichThe account owner of the repository. The name is not case sensitive. |
repo string ErforderlichThe name of the repository without the |
environment_name string ErforderlichThe name of the environment. The name must be URL encoded. For example, any slashes in the name must be replaced with |
Name, type, BESCHREIBUNG |
---|
per_page integer The number of results per page (max 100). For more information, see "Using pagination in the REST API." Standard: |
page integer The page number of the results to fetch. For more information, see "Using pagination in the REST API." Standard: |
HTTP-Antwortstatuscodes für „List deployment branch policies“
Statuscode | BESCHREIBUNG |
---|---|
200 | OK |
Codebeispiele für „List deployment branch policies“
Beispiel für eine Anfrage
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.
Parameter für „Create a deployment branch policy“
Name, type, BESCHREIBUNG |
---|
accept string Setting to |
Name, type, BESCHREIBUNG |
---|
owner string ErforderlichThe account owner of the repository. The name is not case sensitive. |
repo string ErforderlichThe name of the repository without the |
environment_name string ErforderlichThe name of the environment. The name must be URL encoded. For example, any slashes in the name must be replaced with |
Name, type, BESCHREIBUNG |
---|
name string ErforderlichThe name pattern that branches or tags must match in order to deploy to the environment. Wildcard characters will not match |
HTTP-Antwortstatuscodes für „Create a deployment branch policy“
Statuscode | BESCHREIBUNG |
---|---|
200 | OK |
303 | Response if the same branch name pattern already exists |
404 | Not Found or |
Codebeispiele für „Create a deployment branch policy“
Beispiele für Anforderungen
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.
Parameter für „Get a deployment branch policy“
Name, type, BESCHREIBUNG |
---|
accept string Setting to |
Name, type, BESCHREIBUNG |
---|
owner string ErforderlichThe account owner of the repository. The name is not case sensitive. |
repo string ErforderlichThe name of the repository without the |
environment_name string ErforderlichThe 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 ErforderlichThe unique identifier of the branch policy. |
HTTP-Antwortstatuscodes für „Get a deployment branch policy“
Statuscode | BESCHREIBUNG |
---|---|
200 | OK |
Codebeispiele für „Get a deployment branch policy“
Beispiel für eine Anfrage
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.
Parameter für „Update a deployment branch policy“
Name, type, BESCHREIBUNG |
---|
accept string Setting to |
Name, type, BESCHREIBUNG |
---|
owner string ErforderlichThe account owner of the repository. The name is not case sensitive. |
repo string ErforderlichThe name of the repository without the |
environment_name string ErforderlichThe 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 ErforderlichThe unique identifier of the branch policy. |
Name, type, BESCHREIBUNG |
---|
name string ErforderlichThe name pattern that branches must match in order to deploy to the environment. Wildcard characters will not match |
HTTP-Antwortstatuscodes für „Update a deployment branch policy“
Statuscode | BESCHREIBUNG |
---|---|
200 | OK |
Codebeispiele für „Update a deployment branch policy“
Beispiel für eine Anfrage
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.
Parameter für „Delete a deployment branch policy“
Name, type, BESCHREIBUNG |
---|
accept string Setting to |
Name, type, BESCHREIBUNG |
---|
owner string ErforderlichThe account owner of the repository. The name is not case sensitive. |
repo string ErforderlichThe name of the repository without the |
environment_name string ErforderlichThe 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 ErforderlichThe unique identifier of the branch policy. |
HTTP-Antwortstatuscodes für „Delete a deployment branch policy“
Statuscode | BESCHREIBUNG |
---|---|
204 | No Content |
Codebeispiele für „Delete a deployment branch policy“
Beispiel für eine Anfrage
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