Environments API

Environments API

获取给定项目的所有环境.

  1. curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/1/environments?name=review%2Ffix-foo"

响应示例:

  1. [ { "id": 1, "name": "review/fix-foo", "slug": "review-fix-foo-dfjre3", "external_url": "https://review-fix-foo-dfjre3.example.gitlab.com", "state": "available" } ]

Get a specific environment

  1. GET /projects/:id/environments/:environment_id
Attribute Type Required Description
id integer/string yes 经过身份验证的用户拥有的 ID 或URL 编码路径
environment_id integer yes 环境的 ID
  1. curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/1/environments/1"

回应范例

如果成功创建了环境,则返回否则返回400 .

    1. curl --data "name=deploy&external_url=https://deploy.example.gitlab.com" --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/1/environments"

    响应示例:

    1. { "id": 1, "name": "deploy", "slug": "deploy", "external_url": "https://deploy.example.gitlab.com", "state": "available" }

    Edit an existing environment

    更新现有环境的名称和/或external_url .

    1. PUT /projects/:id/environments/:environments_id
    Attribute Type Required Description
    id integer/string yes 经过身份验证的用户拥有的项目的 ID 或
    environment_id integer yes 环境的 ID
    name string no 环境的新名称
    string no 新的external_url

    响应示例:

    1. { "id": 1, "name": "staging", "slug": "staging", "external_url": "https://staging.example.gitlab.com", "state": "available" }

    如果成功删除了环境,则返回204如果环境不存在,则返回404 .

    1. DELETE /projects/:id/environments/:environment_id
    1. curl --request DELETE --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/1/environments/1"

    Stop an environment

    如果成功停止了环境,则返回200如果环境不存在,则返回404 .

    1. POST /projects/:id/environments/:environment_id/stop
    Attribute Type Required Description
    id integer/string yes 经过身份验证的用户拥有的 ID 或URL 编码路径
    environment_id integer yes 环境的 ID
    1. { "id": 1, "name": "deploy", "slug": "deploy", "external_url": "https://deploy.example.gitlab.com", "state": "stopped" }