gitlab-variable
Skill4 starsChanged 10 months agoMITView on GitHub
GitLab CI/CD variable operations. ALWAYS use this skill when user wants to: (1) list CI/CD variables, (2) set/create variables, (3) update variables, (4) delete variables, (5) manage secrets.
- Reads credentials
In this repository19 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- gitlab-assistantSkill
- gitlab-badgeSkill
- gitlab-ciSkill
- gitlab-containerSkill
- gitlab-discussionSkill
- gitlab-fileSkill
- gitlab-groupSkill
- gitlab-issueSkill
- gitlab-labelSkill
- gitlab-milestoneSkill
- gitlab-mrSkill
- gitlab-protected-branchSkill
- gitlab-releaseSkill
- gitlab-repoSkill
- gitlab-searchSkill
- gitlab-vulnerabilitySkill
- gitlab-webhookSkill
- gitlab-wikiSkill
The file
We split this skill into the rules it gives an agent
4 rules. About 0 are common, 2 are distinctive, and 2 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈2
Distinctive · estimate
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 249
Always mask secrets: Use --masked for any sensitive values
- Very specific: line 250
Protect production secrets: Use --protected for production credentials
- Distinctive: line 252
Rotate regularly: Update secrets periodically
- Distinctive: line 253
Avoid logging: Never echo variable values in CI scripts
≈ “Common” is an estimate: at least 1 in 5 of the 213,895 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
CI/CD Variable Skill
CI/CD variable management operations for GitLab using the glab CLI.
Quick Reference
| Operation | Command | Risk |
| List variables | glab variable list | - |
| Get variable | glab variable get <key> | - |
| Set variable | glab variable set <key> <value> | ⚠️ |
| Update variable | glab variable update <key> <value> | ⚠️ |
| Delete variable | glab variable delete <key> | ⚠️⚠️ |
| Export variables | glab variable export | - |
Risk Legend: - Safe | ⚠️ Caution | ⚠️⚠️ Warning | ⚠️⚠️⚠️ Danger
When to Use This Skill
ALWAYS use when:
- User wants to manage CI/CD variables
- User mentions "variable", "secret", "env var", "CI variable", "environment variable"
- User wants to configure build/deployment settings
NEVER use when:
- User wants to run pipelines (use gitlab-ci)
- User wants to manage .env files locally (use file operations)
Available Commands
List Variables
glab variable list [options]Options:
| Flag | Description |
-g, --group=<group> | List group-level variables |
-P, --per-page=<n> | Results per page |
Examples:
# List project variables
glab variable list
# List group variables
glab variable list -g mygroupGet Variable
glab variable get <key> [options]Options:
| Flag | Description |
-g, --group=<group> | Get from group level |
-s, --scope=<scope> | Variable scope/environment |
Examples:
# Get variable value
glab variable get API_KEY
# Get scoped variable
glab variable get DATABASE_URL --scope=productionSet Variable
glab variable set <key> <value> [options]Options:
| Flag | Description |
-g, --group=<group> | Set at group level |
-m, --masked | Mask value in logs |
-p, --protected | Only available in protected branches |
-r, --raw | Value is raw (no expansion) |
-s, --scope=<scope> | Variable scope/environment |
-t, --type=<type> | Variable type: env_var, file |
Examples:
# Set simple variable
glab variable set API_URL "https://api.example.com"
# Set masked secret
glab variable set API_KEY "secret123" --masked
# Set protected variable (only on protected branches)
glab variable set DEPLOY_KEY "key123" --protected --masked
# Set scoped variable for production
glab variable set DATABASE_URL "postgres://prod..." --scope=production
# Set file type variable
glab variable set CONFIG_FILE "$(cat config.json)" --type=file
# Set group variable
glab variable set SHARED_SECRET "secret" -g mygroup --maskedUpdate Variable
glab variable update <key> <value> [options]Same options as set. Updates existing variable.
Examples:
# Update variable value
glab variable update API_KEY "new-secret" --masked
# Update and change scope
glab variable update DATABASE_URL "new-url" --scope=stagingDelete Variable
glab variable delete <key> [options]Options:
| Flag | Description |
-g, --group=<group> | Delete from group level |
-s, --scope=<scope> | Variable scope |
Warning: This permanently deletes the variable.
Examples:
# Delete variable
glab variable delete OLD_API_KEY
# Delete scoped variable
glab variable delete DATABASE_URL --scope=stagingExport Variables
glab variable export [options]Export variables in dotenv format.
Examples:
# Export to stdout
glab variable export
# Export to file
glab variable export > .env.ci
# Export and source
eval $(glab variable export)Variable Types
| Type | Use Case |
env_var | Environment variable (default) |
file | Write value to file, expose path as variable |
Variable Flags
| Flag | Effect |
masked | Value is hidden in job logs |
protected | Only available on protected branches/tags |
raw | No variable expansion (use for JSON, etc.) |
Common Workflows
Workflow 1: Set Up Deployment Variables
# Set production secrets
glab variable set PROD_API_KEY "xxx" --protected --masked --scope=production
glab variable set PROD_DB_URL "postgres://..." --protected --masked --scope=production
# Set staging secrets
glab variable set STAGING_API_KEY "xxx" --masked --scope=staging
glab variable set STAGING_DB_URL "postgres://..." --masked --scope=stagingWorkflow 2: Rotate Secrets
# 1. List current variables
glab variable list
# 2. Update the secret
glab variable update API_KEY "new-secret-value" --masked
# 3. Trigger a new pipeline to use new secret
glab ci runWorkflow 3: Set Up Service Account
# Store credentials as masked file
glab variable set SERVICE_ACCOUNT_JSON "$(cat service-account.json)" \
--type=file --protected --masked
# In CI/CD, use $SERVICE_ACCOUNT_JSON as path to the credentials fileWorkflow 4: Configure Multi-Environment
# Production (protected + masked)
glab variable set DATABASE_URL "postgres://prod..." --scope=production --protected --masked
glab variable set API_KEY "prod-key" --scope=production --protected --masked
# Staging
glab variable set DATABASE_URL "postgres://staging..." --scope=staging --masked
glab variable set API_KEY "staging-key" --scope=staging --masked
# Development
glab variable set DATABASE_URL "postgres://dev..." --scope=development
glab variable set API_KEY "dev-key" --scope=developmentSecurity Best Practices
- Always mask secrets: Use
--maskedfor any sensitive values - Protect production secrets: Use
--protectedfor production credentials - Use scopes: Separate variables by environment
- Rotate regularly: Update secrets periodically
- Avoid logging: Never echo variable values in CI scripts
- Use file type for complex secrets: JSON, certificates, etc.
Troubleshooting
| Issue | Cause | Solution |
| Authentication failed | Invalid/expired token | Run glab auth login |
| Variable not found | Wrong key or scope | Check with glab variable list |
| Cannot see value | Variable is masked | Masked values cannot be retrieved |
| Permission denied | Not maintainer | Need maintainer+ role for variables |
| Value truncated | Special characters | Use --raw flag for complex values |
Related Documentation
- Safeguards
- Quick Reference
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

