glvars CLI tool for import and export project-level Gitlab CI/CD Variables.
- Using environment variables add your personal access token (
apiscope) and project id (optional):
export GLVARS_PRIVATE_TOKEN="your-personal-access-token"
export GLVARS_PROJECT_ID=278964 # Your gitlab project id- Or you can create config file
.glvars.yaml(in$HOMEdirectory):
host: gitlab.example.com # For gitlab server on own domain. By default: https://gitlab.com
private-token: your-gitlab-private-token
project-id: 278964- You also can specify your project id using flag
-por--project:
glvars [command] -p 278964- Export variables in JSON format from project specified in config file or env variable:
glvars exportor you can explicitly specify project id using flag -p:
glvars export -p 278964- To import variables into a project use command
importwith-for--filenameflag with value path to file with array of variables
glvars import -f ./vars.jsonJSON file example:
[
{
"variable_type": "env_var",
"key": "MYSQL_HOST",
"value": "127.0.0.1",
"protected": false,
"masked": false,
"raw": true,
"environment_scope": "production"
},
{
"variable_type": "env_var",
"key": "MYSQL_USER",
"value": "admin",
"protected": false,
"masked": false,
"raw": true,
"environment_scope": "production"
}
]Download a binary suitable for your OS at the release page.
You can build project from source:
go build -o glvars cmd/main.go