Fetch variables from GitLab and inject into environment for local commands
Project description
glvar
CLI for fetching GitLab CI/CD variables and inject them into your local environment for running commands.
Inspired by op, Doppler, pass, etc.
Use Cases
- 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
Installation
Requires Python 3.10+.
# Install with uv
uv tool install glvar
# Or with pip
pip install glvar
Quick Start
# 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
Usage
Configuration
# 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 reset
The 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
Getting Variables
# 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)
Running Commands with Variables
# 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 up
Variables are injected directly into the command's environment without exposing them to your shell history.
Environment Variables
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_PROJECT
Variable Resolution
When fetching from a project path (e.g., mygroup/myproject), glvar checks both:
- Project-level variables (takes precedence)
- Group-level variables
Development
# 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
Security Notes
- 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
License
See LICENSE file for details.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file glvar-0.3.tar.gz.
File metadata
- Download URL: glvar-0.3.tar.gz
- Upload date:
- Size: 10.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8df4cb1a0f8e07fbe8bc3b0f843ce8ac53d84b1e3e7185590217689a87eab94a
|
|
| MD5 |
2bb86d52bec7ff314e888dcffebd9157
|
|
| BLAKE2b-256 |
fadcd71fe52a1e1c712d5072bbadce59a7e40145e7b4966acf4ab3134c71b60b
|
Provenance
The following attestation bundles were made for glvar-0.3.tar.gz:
Publisher:
release.yml on Agama-Technologies/glvar
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
glvar-0.3.tar.gz -
Subject digest:
8df4cb1a0f8e07fbe8bc3b0f843ce8ac53d84b1e3e7185590217689a87eab94a - Sigstore transparency entry: 760348013
- Sigstore integration time:
-
Permalink:
Agama-Technologies/glvar@b91d2c7b648cc631136d7aa9a3d3a35a5c8011a1 -
Branch / Tag:
refs/tags/v0.3 - Owner: https://github.com/Agama-Technologies
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@b91d2c7b648cc631136d7aa9a3d3a35a5c8011a1 -
Trigger Event:
release
-
Statement type:
File details
Details for the file glvar-0.3-py3-none-any.whl.
File metadata
- Download URL: glvar-0.3-py3-none-any.whl
- Upload date:
- Size: 9.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5a048d2ab3cb07e23e557cc85ad58c0c90ff83097c387d4e18bd88a1751c2e05
|
|
| MD5 |
185de505d53f76b5f239a719e3cf1346
|
|
| BLAKE2b-256 |
d035c752e233664f602b841cc146a19e97d257099a26baf3cd97206ef7d1872e
|
Provenance
The following attestation bundles were made for glvar-0.3-py3-none-any.whl:
Publisher:
release.yml on Agama-Technologies/glvar
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
glvar-0.3-py3-none-any.whl -
Subject digest:
5a048d2ab3cb07e23e557cc85ad58c0c90ff83097c387d4e18bd88a1751c2e05 - Sigstore transparency entry: 760348018
- Sigstore integration time:
-
Permalink:
Agama-Technologies/glvar@b91d2c7b648cc631136d7aa9a3d3a35a5c8011a1 -
Branch / Tag:
refs/tags/v0.3 - Owner: https://github.com/Agama-Technologies
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@b91d2c7b648cc631136d7aa9a3d3a35a5c8011a1 -
Trigger Event:
release
-
Statement type: