2016-01-13 17:51:06 +00:00
|
|
|
# Build Variables
|
2016-01-07 13:10:49 +00:00
|
|
|
|
|
|
|
## List project variables
|
|
|
|
|
|
|
|
Get list of variables of a project.
|
|
|
|
|
|
|
|
```
|
|
|
|
GET /projects/:id/variables
|
|
|
|
```
|
|
|
|
|
2016-01-13 19:23:48 +00:00
|
|
|
### Parameters
|
|
|
|
|
|
|
|
| Attribute | Type | required | Description |
|
|
|
|
|-----------|---------|----------|---------------------|
|
|
|
|
| id | integer | yes | The ID of a project |
|
|
|
|
|
|
|
|
### Example of request
|
|
|
|
|
|
|
|
```
|
|
|
|
curl -H "PRIVATE_TOKEN: 9koXpg98eAheJpvBs5tK" "https://gitlab.example.com/api/v3/projects/1/variables"
|
|
|
|
```
|
2016-01-07 13:10:49 +00:00
|
|
|
|
2016-01-13 19:23:48 +00:00
|
|
|
### Example of response
|
2016-01-07 13:10:49 +00:00
|
|
|
|
|
|
|
```json
|
|
|
|
[
|
|
|
|
{
|
|
|
|
"key": "TEST_VARIABLE_1",
|
|
|
|
"value": "TEST_1"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"key": "TEST_VARIABLE_2",
|
|
|
|
"value": "TEST_2"
|
|
|
|
}
|
|
|
|
]
|
|
|
|
```
|
|
|
|
|
|
|
|
## Show variable details
|
|
|
|
|
|
|
|
Get details of specifica variable of a project.
|
|
|
|
|
|
|
|
```
|
|
|
|
GET /projects/:id/variables/:key
|
|
|
|
```
|
|
|
|
|
2016-01-13 19:23:48 +00:00
|
|
|
### Parameters
|
2016-01-07 13:10:49 +00:00
|
|
|
|
2016-01-13 19:23:48 +00:00
|
|
|
| Attribute | Type | required | Description |
|
|
|
|
|-----------|---------|----------|-----------------------|
|
|
|
|
| id | integer | yes | The ID of a project |
|
|
|
|
| key | string | yes | The `key` of variable |
|
|
|
|
|
|
|
|
### Example of request
|
|
|
|
|
|
|
|
```
|
|
|
|
curl -H "PRIVATE_TOKEN: 9koXpg98eAheJpvBs5tK" "https://gitlab.example.com/api/v3/projects/1/variables/TEST_VARIABLE_1"
|
|
|
|
```
|
|
|
|
|
|
|
|
### Example of response
|
2016-01-07 13:10:49 +00:00
|
|
|
|
|
|
|
```json
|
|
|
|
{
|
|
|
|
"key": "TEST_VARIABLE_1",
|
|
|
|
"value": "TEST_1"
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
## Create variable
|
|
|
|
|
|
|
|
Create new variable in project.
|
|
|
|
|
|
|
|
```
|
|
|
|
POST /projects/:id/variables
|
|
|
|
```
|
|
|
|
|
2016-01-13 19:23:48 +00:00
|
|
|
### Parameters
|
|
|
|
|
|
|
|
| Attribute | Type | required | Description |
|
|
|
|
|-----------|---------|----------|-----------------------|
|
|
|
|
| id | integer | yes | The ID of a project |
|
|
|
|
| key | string | yes | The `key` of variable; must have no more than 255 characters; only `A-Z`, `a-z`, `0-9`, and `_` are allowed |
|
|
|
|
| value | string | yes | The `value` of variable |
|
2016-01-07 13:10:49 +00:00
|
|
|
|
2016-01-13 19:23:48 +00:00
|
|
|
### Example of request
|
|
|
|
|
|
|
|
```
|
|
|
|
curl -X POST -H "PRIVATE_TOKEN: 9koXpg98eAheJpvBs5tK" "https://gitlab.example.com/api/v3/projects/1/variables" -F "key=NEW_VARIABLE" -F "value=new value"
|
|
|
|
```
|
|
|
|
|
|
|
|
### Example of response
|
2016-01-07 13:10:49 +00:00
|
|
|
|
|
|
|
```json
|
|
|
|
{
|
|
|
|
"key": "NEW_VARIABLE",
|
|
|
|
"value": "new value"
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
## Update variable
|
|
|
|
|
|
|
|
Update variable.
|
|
|
|
|
|
|
|
```
|
|
|
|
PUT /projects/:id/variables/:key
|
|
|
|
```
|
|
|
|
|
2016-01-13 19:23:48 +00:00
|
|
|
### Parameters
|
2016-01-07 13:10:49 +00:00
|
|
|
|
2016-01-13 19:23:48 +00:00
|
|
|
| Attribute | Type | required | Description |
|
|
|
|
|-----------|---------|----------|-------------------------|
|
|
|
|
| id | integer | yes | The ID of a project |
|
|
|
|
| key | string | yes | The `key` of variable |
|
|
|
|
| value | string | yes | The `value` of variable |
|
|
|
|
|
|
|
|
### Example of request
|
|
|
|
|
|
|
|
```
|
|
|
|
curl -X PUT -H "PRIVATE_TOKEN: 9koXpg98eAheJpvBs5tK" "https://gitlab.example.com/api/v3/projects/1/variables/NEW_VARIABLE" -F "value=updated value"
|
|
|
|
```
|
|
|
|
|
|
|
|
### Example of response
|
2016-01-07 13:10:49 +00:00
|
|
|
|
|
|
|
```json
|
|
|
|
{
|
|
|
|
"key": "NEW_VARIABLE",
|
|
|
|
"value": "updated value"
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
## Remove variable
|
|
|
|
|
|
|
|
Remove variable.
|
|
|
|
|
|
|
|
```
|
|
|
|
DELETE /projects/:id/variables/:key
|
|
|
|
```
|
|
|
|
|
2016-01-13 19:23:48 +00:00
|
|
|
### Parameters
|
|
|
|
|
|
|
|
| Attribute | Type | required | Description |
|
|
|
|
|-----------|---------|----------|-------------------------|
|
|
|
|
| id | integer | yes | The ID of a project |
|
|
|
|
| key | string | yes | The `key` of variable |
|
2016-01-07 13:10:49 +00:00
|
|
|
|
2016-01-13 19:23:48 +00:00
|
|
|
### Example of request
|
|
|
|
|
|
|
|
```
|
|
|
|
curl -X DELETE -H "PRIVATE_TOKEN: 9koXpg98eAheJpvBs5tK" "https://gitlab.example.com/api/v3/projects/1/variables/VARIABLE_1"
|
|
|
|
```
|
2016-01-07 13:10:49 +00:00
|
|
|
|