Maven / GitLab CI Basics Interview Questions
What are the most important predefined CI/CD variables in GitLab?
GitLab automatically sets dozens of predefined variables for every pipeline run. These provide jobs with information about the current commit, branch, pipeline, runner, and environment without any configuration.
| Variable | Value | Common use |
|---|---|---|
| $CI_COMMIT_SHA | Full commit SHA (40 chars) | Tagging Docker images |
| $CI_COMMIT_SHORT_SHA | First 8 chars of SHA | Short image tags, logs |
| $CI_COMMIT_BRANCH | Branch name | Conditional logic (if main...) |
| $CI_COMMIT_REF_NAME | Branch or tag name | Generic ref reference |
| $CI_COMMIT_REF_SLUG | Branch name, URL-safe (/ replaced with -) | Docker tags, URLs |
| $CI_PIPELINE_ID | Unique pipeline ID | Linking artifacts to pipelines |
| $CI_JOB_ID | Unique job ID | Unique artifact names |
| $CI_PROJECT_NAME | Repository name | Build labels |
| $CI_PROJECT_PATH | namespace/project | Registry image paths |
| $CI_REGISTRY | GitLab Container Registry URL | Docker login |
| $CI_REGISTRY_IMAGE | Full image path in registry | docker build/push |
| $GITLAB_USER_LOGIN | Username of who triggered pipeline | Audit logs |
| $CI_PIPELINE_SOURCE | What triggered the pipeline | Conditional job rules |
deploy: script: - docker build -t $CI_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA . - docker push $CI_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA - echo "Deployed by $GITLAB_USER_LOGIN from $CI_COMMIT_BRANCH"
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...
