CLI for fetching GitLab CI/CD variables and inject them into your local environment for running commands.
Inspired by op, Doppler, pass, etc.
- Read API keys for local development
- Run deployments that require secrets/API keys from your machine
- Extract
.envfiles with config options stored in CI/CD variables
Requires Python 3.10+.
# Install with uv
uv tool install glvar
# Or with pip
pip install glvar# Interactive setup (creates token, stores in OS keyring)
glvar config setup
# Get a variable value
glvar get -p mygroup/myproject API_KEY
# Run a command with variables injected
glvar run -p mygroup/myproject API_KEY DB_PASS -- ./deploy.sh
# List available variables
glvar list -p mygroup/myproject
# List projects you have access to
glvar projects# Interactive setup - guides you through creating a GitLab PAT
glvar config setup
# Store token in config file instead of keyring
glvar config setup --no-keyring
# Show current configuration
glvar config show
# Reset configuration (remove token from keyring)
glvar config resetThe setup wizard will:
- Ask for your GitLab URL (defaults to https://gitlab.com)
- Provide a link to create a Personal Access Token with
read_apiscope - Validate the token and store it securely in your OS keyring
# Get a single variable (outputs value only)
glvar get -p mygroup/myproject MY_SECRET
# Get multiple variables in .env format
glvar get -p mygroup/myproject VAR1 VAR2 --format=env > .env
# Get all variables
glvar get -p mygroup/myproject --all --format=env > .env
# Use in shell
export SECRET=$(glvar get -p mygroup/myproject API_KEY)# Inject specific variables into command environment
glvar run -p mygroup/myproject API_KEY DB_PASS -- ./deploy.sh
# Inject all variables
glvar run -p mygroup/myproject --all -- docker-compose upVariables are injected directly into the command's environment without exposing them to your shell history.
You can set defaults via environment variables:
| Variable | Description |
|---|---|
GLVAR_PROJECT |
Default project/group path |
GLVAR_URL |
GitLab URL (overrides config) |
GLVAR_TOKEN |
Access token (overrides keyring) |
export GLVAR_PROJECT=mygroup/myproject
glvar get API_KEY # Uses GLVAR_PROJECTWhen fetching from a project path (e.g., mygroup/myproject), glvar checks both:
- Project-level variables (takes precedence)
- Group-level variables
# Install dependencies
uv sync
# Show make targets
make
make help
# Run linting
make lint
# Format code
make format
# Build package
make build
# Clean build artifacts
make clean- Tokens are stored in your OS keyring (not in plain text files)
- Config file at
~/.config/glvar/config.jsoncontains only the GitLab URL - Be careful when exporting secrets to files - prefer using
glvar runwhen possible
Copyright (c) 2025 Agama Technologies AB
See LICENSE file for details.