2016-07-26 03:37:02 -04:00
|
|
|
# Environments
|
|
|
|
|
|
|
|
## List environments
|
|
|
|
|
|
|
|
Get all environments for a given project.
|
|
|
|
|
|
|
|
```
|
|
|
|
GET /projects/:id/environments
|
|
|
|
```
|
|
|
|
|
|
|
|
| Attribute | Type | Required | Description |
|
|
|
|
| --------- | ------- | -------- | --------------------- |
|
|
|
|
| `id` | integer | yes | The ID of the project |
|
|
|
|
|
|
|
|
```bash
|
2016-08-08 03:47:17 -04:00
|
|
|
curl --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" https://gitlab.example.com/api/v3/projects/1/environments
|
2016-07-26 03:37:02 -04:00
|
|
|
```
|
|
|
|
|
|
|
|
Example response:
|
|
|
|
|
|
|
|
```json
|
|
|
|
[
|
|
|
|
{
|
|
|
|
"id": 1,
|
|
|
|
"name": "Env1",
|
|
|
|
"external_url": "https://env1.example.gitlab.com"
|
|
|
|
}
|
|
|
|
]
|
|
|
|
```
|
|
|
|
|
|
|
|
## Create a new environment
|
|
|
|
|
|
|
|
Creates a new environment with the given name and external_url.
|
|
|
|
|
2016-07-29 06:14:36 -04:00
|
|
|
It returns 201 if the environment was successfully created, 400 for wrong parameters.
|
2016-07-26 03:37:02 -04:00
|
|
|
|
|
|
|
```
|
|
|
|
POST /projects/:id/environment
|
|
|
|
```
|
|
|
|
|
|
|
|
| Attribute | Type | Required | Description |
|
|
|
|
| ------------- | ------- | -------- | ---------------------------- |
|
|
|
|
| `id` | integer | yes | The ID of the project |
|
|
|
|
| `name` | string | yes | The name of the environment |
|
2016-07-26 08:19:37 -04:00
|
|
|
| `external_url` | string | no | Place to link to for this environment |
|
2016-07-26 03:37:02 -04:00
|
|
|
|
|
|
|
```bash
|
2016-08-08 03:47:17 -04:00
|
|
|
curl --data "name=deploy&external_url=https://deploy.example.gitlab.com" --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" "https://gitlab.example.com/api/v3/projects/1/environments"
|
2016-07-26 03:37:02 -04:00
|
|
|
```
|
|
|
|
|
|
|
|
Example response:
|
|
|
|
|
|
|
|
```json
|
|
|
|
{
|
|
|
|
"id": 1,
|
|
|
|
"name": "deploy",
|
|
|
|
"external_url": "https://deploy.example.gitlab.com"
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2016-07-29 06:14:36 -04:00
|
|
|
## Edit an existing environment
|
2016-07-26 03:37:02 -04:00
|
|
|
|
2016-07-29 06:14:36 -04:00
|
|
|
Updates an existing environment's name and/or external_url.
|
|
|
|
|
|
|
|
It returns 200 if the environment was successfully updated. In case of an error, a status code 400 is returned.
|
2016-07-26 03:37:02 -04:00
|
|
|
|
|
|
|
```
|
2016-07-29 06:14:36 -04:00
|
|
|
PUT /projects/:id/environments/:environments_id
|
2016-07-26 03:37:02 -04:00
|
|
|
```
|
|
|
|
|
2016-07-29 06:14:36 -04:00
|
|
|
| Attribute | Type | Required | Description |
|
|
|
|
| --------------- | ------- | --------------------------------- | ------------------------------- |
|
|
|
|
| `id` | integer | yes | The ID of the project |
|
|
|
|
| `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 03:37:02 -04:00
|
|
|
|
|
|
|
```bash
|
2016-08-08 03:47:17 -04:00
|
|
|
curl --request PUT --data "name=staging&external_url=https://staging.example.gitlab.com" --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" "https://gitlab.example.com/api/v3/projects/1/environment/1"
|
2016-07-26 03:37:02 -04:00
|
|
|
```
|
|
|
|
|
|
|
|
Example response:
|
|
|
|
|
|
|
|
```json
|
|
|
|
{
|
|
|
|
"id": 1,
|
2016-07-29 06:14:36 -04:00
|
|
|
"name": "staging",
|
|
|
|
"external_url": "https://staging.example.gitlab.com"
|
2016-07-26 03:37:02 -04:00
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2016-07-29 06:14:36 -04:00
|
|
|
## Delete an environment
|
2016-07-26 03:37:02 -04:00
|
|
|
|
2016-07-29 06:14:36 -04:00
|
|
|
It returns 200 if the environment was successfully deleted, and 404 if the environment does not exist.
|
2016-07-26 03:37:02 -04:00
|
|
|
|
|
|
|
```
|
2016-07-29 06:14:36 -04:00
|
|
|
DELETE /projects/:id/environments/:environment_id
|
2016-07-26 03:37:02 -04:00
|
|
|
```
|
|
|
|
|
2016-07-29 06:14:36 -04:00
|
|
|
| Attribute | Type | Required | Description |
|
|
|
|
| --------- | ------- | -------- | --------------------- |
|
|
|
|
| `id` | integer | yes | The ID of the project |
|
|
|
|
| `environment_id` | integer | yes | The ID of the environment |
|
2016-07-26 03:37:02 -04:00
|
|
|
|
|
|
|
```bash
|
2016-08-08 03:47:17 -04:00
|
|
|
curl --request DELETE --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" "https://gitlab.example.com/api/v3/projects/1/environment/1"
|
2016-07-26 03:37:02 -04:00
|
|
|
```
|
|
|
|
|
|
|
|
Example response:
|
|
|
|
|
|
|
|
```json
|
|
|
|
{
|
|
|
|
"id": 1,
|
2016-07-29 06:14:36 -04:00
|
|
|
"name": "deploy",
|
|
|
|
"external_url": "https://deploy.example.gitlab.com"
|
2016-07-26 03:37:02 -04:00
|
|
|
}
|
|
|
|
```
|