Project-level Variables API
Project-level Variables API
获取项目变量的列表.
curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/1/variables"
[ { "key": "TEST_VARIABLE_1", "variable_type": "env_var", "value": "TEST_1" }, { "key": "TEST_VARIABLE_2", "variable_type": "env_var", "value": "TEST_2" } ]
Show variable details
获取项目特定变量的详细信息.
GET /projects/:id/variables/:key
curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/1/variables/TEST_VARIABLE_1"
创建一个新变量.
POST /projects/:id/variables
curl --request POST --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/1/variables" --form "key=NEW_VARIABLE" --form "value=new value"
Update variable
PUT /projects/:id/variables/:key
{ "key": "NEW_VARIABLE", "value": "updated value", "variable_type": "env_var", "protected": true, "masked": false, "environment_scope": "*" }
删除项目的变量.
DELETE /projects/:id/variables/:key
curl --request DELETE --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/1/variables/VARIABLE_1"
The filter
parameter
版本历史
- 在 GitLab 13.2 中 .
- 它部署在功能标记后面,默认情况下处于禁用状态.
- 在 GitLab.com 上已禁用.
- 要在 GitLab 自管实例中使用它,请让 GitLab 管理员启用它.
此参数用于按属性(例如environment_scope
进行过滤.
curl --request DELETE --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/1/variables/VARIABLE_1?filter[environment_scope]=production"
有权访问 GitLab Rails 控制台的 GitLab 管理员可以为您的实例启用它.
要启用它:
禁用它: