A Python wrapper for retrieving Gitlab CI/CD variables
Project description
Glabvars
A Python wrapper for retrieving Gitlab Ci/CD variables to enable injecting them into locally running GitLab CI/CD pipelines run with gitlab-ci-local
.
Features:
- Retrieve project-level CI/CD variables
- Retrieve (inherited) group-level CI/CD variables
- Support for environment-scoped CI/CD variables
- Support variable-type (normal) and file-type CI/CD variables
- Export to
gitlab-ci-local
YAML configuration file
Usage
Run the glabvars
CLI app inside a git repository with a Gitlab remote.
The application can return a YAML configuration string for gitlab-ci-local
to stdout
.
You can pipe this output to .gitlab-ci-local-variables.yml
so that gitlab-ci-local
can use the variables.
glabvars --target gcl > .gitlab-ci-local-variables.yml
Output targets
Gitlab-CI-Local: gcl
When passing --target gcl
, glabvars
will output to stdout
a YAML configuration file that can be used by gitlab-ci-local
.
Environment: env
When passing --target env
, glabvars
will output .env
files and file-type variable files.
These files are postfixed with .<environment_scope>
if the environment_scope
of a CI/CD variable is not '*'
. These files are written in the --env-path
directory (default: .gitlab
)
Installation
Install with pip
to install globally:
pip install glabvars
Or alternatively with pipx
to isolate dependencies of glabvars
from other globally installed Python apps (requires pipx
):
pipx install glabvars
Requirements
You must have glab
installed and be authenticated with the relevant Gitlab instance to retrieve the CI/CD variables.
Check whether you are authenticated by calling glab auth status
.
Future work
Make it extensible to other targets.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.