Maven / GitLab CI Basics Interview Questions
What are GitLab CI/CD variables and what types are available?
CI/CD variables are key-value pairs that make values available to jobs. They are used to configure jobs without hardcoding values, store secrets safely, and pass information between pipeline components.
| Type | Where defined | Use case |
|---|---|---|
| Predefined variables | Set automatically by GitLab | Pipeline metadata: $CI_COMMIT_SHA, $CI_COMMIT_BRANCH |
| Project variables | Settings > CI/CD > Variables | Project-specific secrets: API keys, passwords |
| Group variables | Group > Settings > CI/CD > Variables | Shared secrets across projects in a group |
| Instance variables | Admin area > CI/CD > Variables | Shared across the entire GitLab instance |
| .gitlab-ci.yml variables | variables: keyword in YAML | Non-secret config values |
# Defining variables in .gitlab-ci.yml variables: DATABASE_URL: "postgres://localhost/mydb" # available to all jobs DEPLOY_ENV: "staging" build-job: variables: NODE_ENV: "production" # job-level variable (overrides global) script: - echo "Branch: $CI_COMMIT_BRANCH" - echo "Commit: $CI_COMMIT_SHA" - echo "DB: $DATABASE_URL" - echo "Node env: $NODE_ENV"
Security settings for project/group variables:
- Masked - value is hidden in job logs (must be a single line, no spaces)
- Protected - variable only available to jobs running on protected branches or tags
- Expanded - controls whether
$VARreferences within the value are expanded
Invest now in Acorns!!! 🚀
Join Acorns and get your $5 bonus!
Acorns is a micro-investing app that automatically invests your "spare change" from daily purchases into diversified, expert-built portfolios of ETFs. It is designed for beginners, allowing you to start investing with as little as $5. The service automates saving and investing. Disclosure: I may receive a referral bonus.
Invest now!!! Get Free equity stock (US, UK only)!
Use Robinhood app to invest in stocks. It is safe and secure. Use the Referral link to claim your free stock when you sign up!.
The Robinhood app makes it easy to trade stocks, crypto and more.
Webull! Receive free stock by signing up using the link: Webull signup.
More Related questions...
