Maven / GitLab CI Basics Interview Questions
What is a CI/CD job in GitLab and what are the required keywords?
A job is the fundamental unit of work in a GitLab pipeline. It defines a set of shell commands to run, where to run them, and under what conditions. Jobs run independently on runners and produce a job log accessible in the GitLab UI.
# Minimum viable job (only "script" is required): hello-world: script: - echo "Hello, World!" # Full job with common keywords: build-app: stage: build image: node:20-alpine before_script: - npm ci script: - npm run build after_script: - echo "Build complete" artifacts: paths: - dist/ rules: - if: $CI_COMMIT_BRANCH == "main"
| Keyword | Purpose | Required? |
|---|---|---|
| script | Commands to execute - the job's main work | Yes |
| stage | Which stage this job belongs to | No (defaults to 'test') |
| image | Docker image to use as the job environment | No |
| before_script | Commands that run before script (setup) | No |
| after_script | Commands that run after script (cleanup, always runs) | No |
| artifacts | Files/dirs to save and pass to later jobs | No |
| rules | Conditions that determine when the job runs | No |
| tags | Specify which runner to use by tag | No |
Jobs must be defined at the top level of the YAML file. Any YAML key not matching a reserved keyword is treated as a job name. Job names starting with a dot (e.g. .setup) are hidden jobs - they don't run but can be used as templates.
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...
