2017-05-10 18:48:07 +00:00
|
|
|
# Environments API
|
2016-07-26 07:37:02 +00:00
|
|
|
|
|
|
|
## List environments
|
|
|
|
|
|
|
|
Get all environments for a given project.
|
|
|
|
|
|
|
|
```
|
|
|
|
GET /projects/:id/environments
|
|
|
|
```
|
|
|
|
|
|
|
|
| Attribute | Type | Required | Description |
|
|
|
|
| --------- | ------- | -------- | --------------------- |
|
2017-04-08 09:21:11 +00:00
|
|
|
| `id` | integer/string | yes | The ID or [URL-encoded path of the project](README.md#namespaced-path-encoding) owned by the authenticated user |
|
2016-07-26 07:37:02 +00:00
|
|
|
|
|
|
|
```bash
|
2018-12-27 09:03:08 +00:00
|
|
|
curl --header "PRIVATE-TOKEN: <your_access_token>" https://gitlab.example.com/api/v4/projects/1/environments
|
2016-07-26 07:37:02 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
Example response:
|
|
|
|
|
|
|
|
```json
|
|
|
|
[
|
|
|
|
{
|
|
|
|
"id": 1,
|
2016-12-08 01:09:18 +00:00
|
|
|
"name": "review/fix-foo",
|
|
|
|
"slug": "review-fix-foo-dfjre3",
|
|
|
|
"external_url": "https://review-fix-foo-dfjre3.example.gitlab.com"
|
2016-07-26 07:37:02 +00:00
|
|
|
}
|
|
|
|
]
|
|
|
|
```
|
|
|
|
|
|
|
|
## Create a new environment
|
|
|
|
|
|
|
|
Creates a new environment with the given name and external_url.
|
|
|
|
|
2017-02-28 13:55:21 +00:00
|
|
|
It returns `201` if the environment was successfully created, `400` for wrong parameters.
|
2016-07-26 07:37:02 +00:00
|
|
|
|
|
|
|
```
|
2017-11-15 22:44:07 +00:00
|
|
|
POST /projects/:id/environments
|
2016-07-26 07:37:02 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
| Attribute | Type | Required | Description |
|
|
|
|
| ------------- | ------- | -------- | ---------------------------- |
|
2017-04-08 09:21:11 +00:00
|
|
|
| `id` | integer/string | yes | The ID or [URL-encoded path of the project](README.md#namespaced-path-encoding) owned by the authenticated user |
|
2016-07-26 07:37:02 +00:00
|
|
|
| `name` | string | yes | The name of the environment |
|
2016-07-26 12:19:37 +00:00
|
|
|
| `external_url` | string | no | Place to link to for this environment |
|
2016-07-26 07:37:02 +00:00
|
|
|
|
|
|
|
```bash
|
2018-12-27 09:03:08 +00:00
|
|
|
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"
|
2016-07-26 07:37:02 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
Example response:
|
|
|
|
|
|
|
|
```json
|
|
|
|
{
|
|
|
|
"id": 1,
|
|
|
|
"name": "deploy",
|
2016-12-08 01:09:18 +00:00
|
|
|
"slug": "deploy",
|
2016-07-26 07:37:02 +00:00
|
|
|
"external_url": "https://deploy.example.gitlab.com"
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2016-07-29 10:14:36 +00:00
|
|
|
## Edit an existing environment
|
2016-07-26 07:37:02 +00:00
|
|
|
|
2016-07-29 10:14:36 +00:00
|
|
|
Updates an existing environment's name and/or external_url.
|
|
|
|
|
2017-02-28 13:55:21 +00:00
|
|
|
It returns `200` if the environment was successfully updated. In case of an error, a status code `400` is returned.
|
2016-07-26 07:37:02 +00:00
|
|
|
|
|
|
|
```
|
2016-07-29 10:14:36 +00:00
|
|
|
PUT /projects/:id/environments/:environments_id
|
2016-07-26 07:37:02 +00:00
|
|
|
```
|
|
|
|
|
2016-07-29 10:14:36 +00:00
|
|
|
| Attribute | Type | Required | Description |
|
|
|
|
| --------------- | ------- | --------------------------------- | ------------------------------- |
|
2017-04-08 09:21:11 +00:00
|
|
|
| `id` | integer/string | yes | The ID or [URL-encoded path of the project](README.md#namespaced-path-encoding) owned by the authenticated user |
|
2016-07-29 10:14:36 +00:00
|
|
|
| `environment_id` | integer | yes | The ID of the environment | The ID of the environment |
|
|
|
|
| `name` | string | no | The new name of the environment |
|
|
|
|
| `external_url` | string | no | The new external_url |
|
2016-07-26 07:37:02 +00:00
|
|
|
|
|
|
|
```bash
|
2018-12-27 09:03:08 +00:00
|
|
|
curl --request PUT --data "name=staging&external_url=https://staging.example.gitlab.com" --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/1/environments/1"
|
2016-07-26 07:37:02 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
Example response:
|
|
|
|
|
|
|
|
```json
|
|
|
|
{
|
|
|
|
"id": 1,
|
2016-07-29 10:14:36 +00:00
|
|
|
"name": "staging",
|
2016-12-08 01:09:18 +00:00
|
|
|
"slug": "staging",
|
2016-07-29 10:14:36 +00:00
|
|
|
"external_url": "https://staging.example.gitlab.com"
|
2016-07-26 07:37:02 +00:00
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2016-07-29 10:14:36 +00:00
|
|
|
## Delete an environment
|
2016-07-26 07:37:02 +00:00
|
|
|
|
2017-09-06 07:15:34 +00:00
|
|
|
It returns `204` if the environment was successfully deleted, and `404` if the environment does not exist.
|
2016-07-26 07:37:02 +00:00
|
|
|
|
|
|
|
```
|
2016-07-29 10:14:36 +00:00
|
|
|
DELETE /projects/:id/environments/:environment_id
|
2016-07-26 07:37:02 +00:00
|
|
|
```
|
|
|
|
|
2016-07-29 10:14:36 +00:00
|
|
|
| Attribute | Type | Required | Description |
|
|
|
|
| --------- | ------- | -------- | --------------------- |
|
2017-04-08 09:21:11 +00:00
|
|
|
| `id` | integer/string | yes | The ID or [URL-encoded path of the project](README.md#namespaced-path-encoding) owned by the authenticated user |
|
2016-07-29 10:14:36 +00:00
|
|
|
| `environment_id` | integer | yes | The ID of the environment |
|
2016-07-26 07:37:02 +00:00
|
|
|
|
|
|
|
```bash
|
2018-12-27 09:03:08 +00:00
|
|
|
curl --request DELETE --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/1/environments/1"
|
2016-07-26 07:37:02 +00:00
|
|
|
```
|
2017-02-28 13:55:21 +00:00
|
|
|
|
|
|
|
## Stop an environment
|
|
|
|
|
|
|
|
It returns `200` if the environment was successfully stopped, and `404` if the environment does not exist.
|
|
|
|
|
|
|
|
```
|
|
|
|
POST /projects/:id/environments/:environment_id/stop
|
|
|
|
```
|
|
|
|
|
|
|
|
| Attribute | Type | Required | Description |
|
|
|
|
| --------- | ------- | -------- | --------------------- |
|
2017-04-08 09:21:11 +00:00
|
|
|
| `id` | integer/string | yes | The ID or [URL-encoded path of the project](README.md#namespaced-path-encoding) owned by the authenticated user |
|
2017-02-28 13:55:21 +00:00
|
|
|
| `environment_id` | integer | yes | The ID of the environment |
|
|
|
|
|
|
|
|
```bash
|
2018-12-27 09:03:08 +00:00
|
|
|
curl --request POST --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/1/environments/1/stop"
|
2017-02-28 13:55:21 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
Example response:
|
|
|
|
|
|
|
|
```json
|
|
|
|
{
|
|
|
|
"id": 1,
|
|
|
|
"name": "deploy",
|
|
|
|
"slug": "deploy",
|
|
|
|
"external_url": "https://deploy.example.gitlab.com"
|
|
|
|
}
|
|
|
|
```
|