1 unstable release
0.1.0 | Sep 26, 2024 |
---|
#1247 in Rust patterns
25KB
523 lines
gl-env
Bulk-edit Group- and Project-level CI/CD variables in GitLab.
This tools allows you to define your desired variables in a YAML file, and then diff or apply them automatically.
Features
- Dump existing variables to YAML
- Diff between desired and current values
- Apply variables from local file
- Support for different environment scopes
Usage
Start off by dumping existing variables into a YAML-File
gl-env dump -p mygroup/myproject > myproject.yml
Alternatively, create a file from scratch:
# Default configuration to apply to all variables.
#
# The same attributes can be applied to individual variables.
defaults:
# Whether to mask the value in job logs.
# NOTE: masked variable values must
# - be a single line with no spaces
# - be at least 8 characters long
# - not match the name of an existing or predefined CI/CD variable
# - not include special characters other than `@`, `_`, `-`, `:`, `+`
# Default: `false`
masked: false
# Export variable to pipelines running on protected branches and tags only.
# Default: `false`
protected: false
# Don't expand references to other variables.
# `$` will be treated as the start of a reference to another variable.
# Default: `false`
raw: false
# Variables valid for ALL environments (`*`)
variables:
KEY:
value: The value!
raw: true
ANOTHER:
value: some-val
# Variables only valid for specific environments
environment:
test:
MYSERVICE_KEY:
value: test-environment-api-key
prod:
MYSERVICE_KEY:
value: production-environment-api-key
You can then use the diff
and apply
subcommands:
gl-env diff -p mygroup/myproject < myproject.yml
# edit myproject.yml
gl-env apply -p mygroup/myproject < myproject.yml
See gl-env help
to get complete usage information.
Backlog
- Support group-level variables or instance-level variables
- Non-ugly error messages
- String-or-struct for variables (?)
- Remove obsolete variables
- Default settings for all variables
- diff
- apply
- Support identically-named variables in different environments
- Ensure output order of variables is stable
- apply: List variables that are defined in GitLab but not locally
License
Licensed under the MIT license.
Dependencies
~7.5MB
~137K SLoC