Variables and Secrets
Part of the GitLab CI course
A pipeline that behaves exactly the same no matter who pushed it, or which branch they pushed to, cannot tell staging from production, and it cannot tell a real deploy key from a placeholder. Every serious pipeline needs to know things at the moment it runs: which commit it is building, which branch triggered it, and how to authenticate to a database or a cloud API without printing that password somewhere a...
Picture a printed form with a blank line on it: "Environment: ______". The form itself, .gitlab-ci.yml, is identical for everyone who runs the pipeline, but the value written into that blank changes depending on the situation. In GitLab CI, a variable is exactly that kind of labeled slot: a name that holds a piece of text, which any job's script: lines can read back later by putting a dollar sign in front of the...
Want to learn GitLab CI Variables and Secrets in a real environment?
Click below, get a fresh Linux box with GitLab CI ready to go, and work through Variables and Secrets hands-on with an AI tutor that knows your code.
Start this lessonVariables and SecretsWhat you'll learn
- Variables block
- Predefined CI variables
- CI_COMMIT_SHA
- CI_PROJECT_DIR
- Masked variables
- Protected variables
- .env files vs CI variables
Read this lesson in your language
All lessons in this course
11 lessons- 1What Is CI/CD20 min
- 2Your First Pipeline25 min
- 3Jobs and Stages30 min
- 4Variables and Secrets30 min
- 5Artifacts and Caches30 min
- 6Rules and Conditional Jobs30 min
- 7Docker Jobs and Services35 min
- 8Environments and Deployments30 min
- 9Includes and Templates30 min
- 10Runners30 min
- 11Capstone: Build, Test, Deploy60 min
