Glab variable

From vince-winkintel/gitlab-cli-skills · View interactive version

Glab variable is an AI agent skill from the GitHub repository vince-winkintel/gitlab-cli-skills. Manage CI/CD variables at project and group level including create, update, import, export, list, and delete operations. Use when setting environment variables for pipelines, managing secrets, migrating variables, or configuring CI/CD variables. Triggers on variable, CI variable, environment variabl

How to use this skill

Skill file

glab variable

Current captured help and immutable provenance: command reference. Older command captures retain their original provenance and describe earlier interfaces.

Help provenance — capture key 206ebab4f: official macOS arm64 release binary, source commit 206ebab4fc3fa590b720d2885ac890c195c46650; binary archive SHA-256 905271694af2dd68cc254d9a2f3dae80036e5c752a82ea16dec5220f4bff1de7. Applies only to adjacent 206ebab4f markers; complete binary stdout is preserved except trailing spaces/tabs. Historical references retain their own provenance. This attribution is kept inline for single-file exports that omit references and VERSION.

Scoped group updates and deletes

For group variables, update and delete send --scope as an exact environment-scope filter; the default is *. Group environment scopes require Premium/Ultimate. A scope such as review/* names that stored scope; it is not permission to mutate every matching variable. Group update first reads the requested key/scope and refuses a missing or mismatched scope, preventing a mistyped scope from changing another definition. Delete sends the same exact-scope filter to the API. Obtain explicit user authorization for the host, group, key, exact scope, and intended change/deletion; retain protected value input and never print secret values during verification.

Inherited reads and partial updates

variable get KEY --inherited tries the selected project or group, then parent groups closest first, then instance variables. Missing or unreadable levels (404/401/403) are skipped; other failures are returned. --scope filters project/group variables, but not instance variables. This is a lookup of stored definitions, not a full simulation of every CI variable precedence rule. Both text and JSON output can expose secret values; send them only to an approved consumer.

variable update preserves optional attributes unless supplied. Omitted --protected, --masked, --raw, --type, and --description retain their existing values. Use an explicit boolean such as --protected=false only when that policy change is approved. The value is still supplied positionally, through --value, or from stdin; do not invoke this as a metadata-only update with empty stdin, which can replace the value with an empty string. --scope retains its existing targeting behavior.

Overview

<!-- help-capture: 206ebab4f:0e323ff1e4fd -->


  Variables store configuration and secrets used by CI/CD pipelines.

  Each subcommand acts on the current project by default. Use
  `--group` to manage a group's variables instead.


  USAGE

    glab variable [command] [--flags]

  COMMANDS

    delete <key> [--flags]          Delete a variable for a project or group.
    export [--flags]                Export variables from a project or group.
    get <key> [--flags]             Get a variable for a project or group.
    import [--flags]                Import variables from a JSON file or standard input.
    list [--flags]                  List variables for a project or group.
    set <key> <value> [--flags]     Create a new variable for a project or group.
    update <key> <value> [--flags]  Update an existing variable for a project or group.

  FLAGS

    -h --help                       Show help for this command.
    -R --repo                       Select another repository. You can use either OWNER/REPO or GROUP/NAMESPACE/REPO. The full URL or Git URL is also accepted.

Quick start

glab variable --help

Export and import variables

glab variable import consumes the same JSON array shape emitted by glab variable export --output json. It reads standard input by default or a file passed with --input-file / -i.

# Preview and preserve an export before importing it elsewhere
glab variable export --output json > variables.json
glab variable import --input-file variables.json -R group/target-project

# Pipe between groups
glab variable export --group source-group |
  glab variable import --group target-group

# Continue when target variables already exist
glab variable import --input-file variables.json --skip-existing

Import stops when a target variable already exists unless --skip-existing is set. Hidden variable values are omitted from exports, so those entries are skipped with a warning during import; recreate their values explicitly with glab variable set --hidden from an approved secret source. Treat export files as sensitive, keep them out of version control, and verify the target project or group before importing.

Masked and hidden group variables

glab variable set now sends --masked and --hidden correctly for group-level variables. Use explicit flags, verify the target group, and never print the value during confirmation:

glab variable set DEPLOY_TOKEN "$DEPLOY_TOKEN" \
  --group group/subgroup \
  --masked \
  --hidden \
  --protected

# Inspect only approved metadata; the raw JSON includes the value
glab variable get DEPLOY_TOKEN --group group/subgroup --output json \
  --jq '{key, protected, masked, hidden, environment_scope}'

Masking and hiding are server-enforced properties, not substitutes for least privilege or rotation. If GitLab rejects a value because it does not satisfy masking rules, do not weaken the setting silently; fix the value format or get explicit operator approval for a different policy.

Subcommands

See current command help for captured --help output. Earlier captures remain in the historical reference.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.