Skip to main content

Fetch variables from GitLab and inject into environment for local commands

Project description

glvar

PyPI

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

Copyright (c) 2025 Agama Technologies AB

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.5.tar.gz (10.6 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.5-py3-none-any.whl (10.2 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for glvar-0.5.tar.gz
Algorithm Hash digest
SHA256 74f8c30a5975c2965ab512748684071bdf91454125d6e90ba36f3c5e6488498c
MD5 2902e09ca877f99231dcb145d332d4db
BLAKE2b-256 1783ef1661c8b8880d2da8af2f3b43acd771041bdc5f53094b2ca75c866f0df8

See more details on using hashes here.

Provenance

The following attestation bundles were made for glvar-0.5.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.5-py3-none-any.whl.

File metadata

  • Download URL: glvar-0.5-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.5-py3-none-any.whl
Algorithm Hash digest
SHA256 2fd109c43ca09b0b5137ddcff8463aa4d190bc5aee3c69dba4e4289e5c12d876
MD5 bc8e55ceed24d6d8feb0ef40725abadc
BLAKE2b-256 6c944baf564b30f92979d1000ac71c7e36ce5a9a8228126b7346c32fc66da377

See more details on using hashes here.

Provenance

The following attestation bundles were made for glvar-0.5-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