Skip to main content

Эта версия GitHub Enterprise Server была прекращена 2024-03-26. Исправления выпускаться не будут даже при критических проблемах безопасности. Для повышения производительности, повышения безопасности и новых функций выполните обновление до последней версии GitHub Enterprise Server. Чтобы получить справку по обновлению, обратитесь в службу поддержки GitHub Enterprise.

После обновления экземпляра Enterprise Server администратором сайта до Enterprise Server 3.9 или более поздней версии, REST API будет версии. Сведения о том, как найти версию экземпляра, см. в разделе "Сведения о версиях документов GitHub". Дополнительные сведения см. в разделе "О управлении версиями API".

Конечные точки REST API для политик ветви развертывания

Используйте REST API для управления настраиваемыми политиками ветви развертывания.

Сведения о политиках ветви развертывания

С помощью REST API можно указать пользовательские шаблоны имен, которые должны соответствовать ветвям для развертывания в среде. Необходимо задать свойство true для среды, чтобы разрешить deployment_branch_policy.custom_branch_policies использовать эти конечные точки. Сведения об обновлении deployment_branch_policy среды см. в разделе "Конечные точки REST API для сред развертывания".

Дополнительные сведения об ограничении развертываний среды в определенных ветвях см. в разделе "Использование сред для развертывания".

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.

Параметры для "List deployment branch policies"

Заголовки
Имя., Тип, Description
accept string

Setting to application/vnd.github+json is recommended.

Параметры пути
Имя., Тип, Description
owner string Обязательное поле

The account owner of the repository. The name is not case sensitive.

repo string Обязательное поле

The name of the repository without the .git extension. The name is not case sensitive.

environment_name string Обязательное поле

The name of the environment. The name must be URL encoded. For example, any slashes in the name must be replaced with %2F.

Параметры запроса
Имя., Тип, Description
per_page integer

The number of results per page (max 100). For more information, see "Using pagination in the REST API."

По умолчанию.: 30

page integer

The page number of the results to fetch. For more information, see "Using pagination in the REST API."

По умолчанию.: 1

Коды состояния http-ответа для "List deployment branch policies"

Код состоянияОписание
200

OK

Примеры кода для "List deployment branch policies"

Пример запроса

get/repos/{owner}/{repo}/environments/{environment_name}/deployment-branch-policies
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.

Параметры для "Create a deployment branch policy"

Заголовки
Имя., Тип, Description
accept string

Setting to application/vnd.github+json is recommended.

Параметры пути
Имя., Тип, Description
owner string Обязательное поле

The account owner of the repository. The name is not case sensitive.

repo string Обязательное поле

The name of the repository without the .git extension. The name is not case sensitive.

environment_name string Обязательное поле

The name of the environment. The name must be URL encoded. For example, any slashes in the name must be replaced with %2F.

Параметры запроса
Имя., Тип, Description
name string Обязательное поле

The name pattern that branches or tags must match in order to deploy to the environment.

Wildcard characters will not match /. For example, to match branches that begin with release/ and contain an additional single slash, use release/*/*. For more information about pattern matching syntax, see the Ruby File.fnmatch documentation.

Коды состояния http-ответа для "Create a deployment branch policy"

Код состоянияОписание
200

OK

303

Response if the same branch name pattern already exists

404

Not Found or deployment_branch_policy.custom_branch_policies property for the environment is set to false

Примеры кода для "Create a deployment branch policy"

Примеры запросов

post/repos/{owner}/{repo}/environments/{environment_name}/deployment-branch-policies
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.

Параметры для "Get a deployment branch policy"

Заголовки
Имя., Тип, Description
accept string

Setting to application/vnd.github+json is recommended.

Параметры пути
Имя., Тип, Description
owner string Обязательное поле

The account owner of the repository. The name is not case sensitive.

repo string Обязательное поле

The name of the repository without the .git extension. The name is not case sensitive.

environment_name string Обязательное поле

The name of the environment. The name must be URL encoded. For example, any slashes in the name must be replaced with %2F.

branch_policy_id integer Обязательное поле

The unique identifier of the branch policy.

Коды состояния http-ответа для "Get a deployment branch policy"

Код состоянияОписание
200

OK

Примеры кода для "Get a deployment branch policy"

Пример запроса

get/repos/{owner}/{repo}/environments/{environment_name}/deployment-branch-policies/{branch_policy_id}
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.

Параметры для "Update a deployment branch policy"

Заголовки
Имя., Тип, Description
accept string

Setting to application/vnd.github+json is recommended.

Параметры пути
Имя., Тип, Description
owner string Обязательное поле

The account owner of the repository. The name is not case sensitive.

repo string Обязательное поле

The name of the repository without the .git extension. The name is not case sensitive.

environment_name string Обязательное поле

The name of the environment. The name must be URL encoded. For example, any slashes in the name must be replaced with %2F.

branch_policy_id integer Обязательное поле

The unique identifier of the branch policy.

Параметры запроса
Имя., Тип, Description
name string Обязательное поле

The name pattern that branches must match in order to deploy to the environment.

Wildcard characters will not match /. For example, to match branches that begin with release/ and contain an additional single slash, use release/*/*. For more information about pattern matching syntax, see the Ruby File.fnmatch documentation.

Коды состояния http-ответа для "Update a deployment branch policy"

Код состоянияОписание
200

OK

Примеры кода для "Update a deployment branch policy"

Пример запроса

put/repos/{owner}/{repo}/environments/{environment_name}/deployment-branch-policies/{branch_policy_id}
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.

Параметры для "Delete a deployment branch policy"

Заголовки
Имя., Тип, Description
accept string

Setting to application/vnd.github+json is recommended.

Параметры пути
Имя., Тип, Description
owner string Обязательное поле

The account owner of the repository. The name is not case sensitive.

repo string Обязательное поле

The name of the repository without the .git extension. The name is not case sensitive.

environment_name string Обязательное поле

The name of the environment. The name must be URL encoded. For example, any slashes in the name must be replaced with %2F.

branch_policy_id integer Обязательное поле

The unique identifier of the branch policy.

Коды состояния http-ответа для "Delete a deployment branch policy"

Код состоянияОписание
204

No Content

Примеры кода для "Delete a deployment branch policy"

Пример запроса

delete/repos/{owner}/{repo}/environments/{environment_name}/deployment-branch-policies/{branch_policy_id}
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