Maven / GitLab CI Basics Interview Questions
What is the 'extends' keyword and how does it enable job templates?
The extends keyword lets one job inherit configuration from another job (or a hidden job used as a template). This reduces duplication and keeps the pipeline DRY (Don't Repeat Yourself).
# Define a hidden job template (starts with .) .base-deploy: image: alpine:latest before_script: - apk add --no-cache curl - echo "Logging into registry..." after_script: - echo "Deployment complete" rules: - if: $CI_COMMIT_BRANCH == "main" # Jobs extend the template deploy-staging: extends: .base-deploy script: - ./deploy.sh staging environment: name: staging deploy-production: extends: .base-deploy script: - ./deploy.sh production environment: name: production rules: # overrides the template rules - if: $CI_COMMIT_TAG when: manual # extends with multiple parents (array form) .logging: after_script: - send-logs.sh my-job: extends: - .base-deploy - .logging # merges config from both (later parent wins on conflict)
Merge behaviour: when a job extends a template, YAML hashes are merged deeply. Arrays (like script, rules) in the child job replace (not append to) the parent's arrays. A job can extend multiple templates by providing an array - conflicts are resolved with the last-listed parent winning, then the child overriding all.
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...
