Skip to main content

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 .env files 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:

  1. Ask for your GitLab URL (defaults to https://gitlab.com)
  2. Provide a link to create a Personal Access Token with read_api scope
  3. 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:

  1. Project-level variables (takes precedence)
  2. 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.json contains only the GitLab URL
  • Be careful when exporting secrets to files - prefer using glvar run when 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

glvar-0.4.tar.gz (10.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

glvar-0.4-py3-none-any.whl (10.2 kB view details)

Uploaded Python 3

File details

Details for the file glvar-0.4.tar.gz.

File metadata

  • Download URL: glvar-0.4.tar.gz
  • Upload date:
  • Size: 10.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for glvar-0.4.tar.gz
Algorithm Hash digest
SHA256 f607a648f615a494e59b897c7593e0360dbd782dadcfc7cf87e49116b14cad38
MD5 321c79bca64c9a3525ee0c1711344355
BLAKE2b-256 77a00994ccb7da48713770263c88ad86dc4af6c19338817799055be5796efe65

See more details on using hashes here.

Provenance

The following attestation bundles were made for glvar-0.4.tar.gz:

Publisher: release.yml on Agama-Technologies/glvar

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file glvar-0.4-py3-none-any.whl.

File metadata

  • Download URL: glvar-0.4-py3-none-any.whl
  • Upload date:
  • Size: 10.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for glvar-0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 6a3b4a94dfc2c1a2a81d32db2bb7df742f3bdcf488e3c7d691a250a2ab9d2519
MD5 59cbbba42cd3b32b1625fdd4fa901d17
BLAKE2b-256 d6fa253590ef57b708f36cc54e48bfdb45f7e23ad20e71bd44d2ea1754012bc3

See more details on using hashes here.

Provenance

The following attestation bundles were made for glvar-0.4-py3-none-any.whl:

Publisher: release.yml on Agama-Technologies/glvar

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page