LinuxCommandLibrary
GitHubF-DroidGoogle Play Store

glab-variable

Manage GitLab CI/CD variables from the command line

TLDR

List variables for the current project
$ glab variable list
copy
List variables for a group
$ glab variable list -g [group]
copy
Print one variable
$ glab variable get [key]
copy
Set a variable
$ glab variable set [key] "[value]"
copy
Set a masked, protected variable for one environment
$ glab variable set [key] "[value]" -m -p -s "[scope]"
copy
Store the value as a file variable
$ glab variable set [key] "[value]" -t file
copy
Export project variables as shell assignments
$ glab variable export -F env
copy
Delete a variable
$ glab variable delete [key]
copy

SYNOPSIS

glab variable command [flags]

DESCRIPTION

glab variable manages CI/CD variables for a GitLab project or group. It is a subcommand of glab, not a separate program. Commands that do not pass -g use the project that matches the git remote in the current directory.A masked variable is hidden in job logs. A protected variable is exposed only to pipelines on protected refs. A file variable is written to a temporary file when a job starts, and the job sees the path instead of the raw text. The default type is an environment variable injected into the job.

PARAMETERS

list

List variables. -g selects a group instead of the current project.
get key
Print the value of one variable.
set key value
Create or update a variable. -m masks it in job logs. -p makes it available only on protected branches and tags. -s limits it to an environment scope. -t sets the type: file, or an environment variable (the default).
export
Print variables as assignments. -F env writes them in a form a shell can source.
delete key
Delete a project variable.
-h, --help
Show help and exit.

INSTALL

sudo apt install glab
copy
sudo dnf install glab
copy
sudo pacman -S glab
copy
sudo apk add glab
copy
sudo zypper install glab
copy
brew install glab
copy
nix profile install nixpkgs#glab
copy

CAVEATS

get and export print secret values to the terminal. Group variables and project variables are different stores; -g is required to see the group ones. A protected variable is missing from pipelines that do not run on a protected ref.

SEE ALSO

RESOURCES

Copied to clipboard
Kai