Maven / GitLab CI Basics Interview Questions
What is the 'default' keyword in GitLab CI and how does it reduce duplication?
The default keyword defines configuration that applies to all jobs in the pipeline unless overridden at the job level. It acts as a global default for common settings, reducing repetition across many jobs.
# Set defaults for all jobs default: image: ubuntu:24.04 before_script: - apt-get update -qq - echo "Setting up environment..." after_script: - echo "Job complete" retry: max: 1 when: runner_system_failure timeout: 1 hour interruptible: true # allow newer pipelines to cancel this job # Jobs inherit defaults but can override individual settings: build-job: image: node:20-alpine # overrides the default ubuntu image script: - npm ci && npm run build # before_script from default still runs python-test: # uses all defaults: ubuntu image, before_script, retry, timeout script: - pip install -r requirements.txt - pytest before_script: - pip install --upgrade pip # overrides global before_script entirely
| Keyword | Effect when set globally |
|---|---|
| image | Default Docker image for all jobs |
| before_script | Setup commands prepended to every job |
| after_script | Cleanup commands appended to every job |
| retry | Default retry behaviour for all jobs |
| timeout | Default job timeout |
| interruptible | Whether newer pipelines can cancel pending jobs |
| artifacts | Default artifact paths |
| cache | Default cache configuration |
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...
