Maven / GitLab CI Basics Interview Questions
What is the 'include' keyword and how do you share CI configuration across projects?
The include keyword lets you split pipeline configuration across multiple files or pull shared configuration from external sources. This is the foundation for sharing CI standards across many projects in an organisation.
| Type | Syntax | Use case |
|---|---|---|
| local | include: local: '/templates/jobs.yml' | Another file in the same repository |
| project | include: project: 'group/repo', file: '/ci/template.yml' | File in another GitLab project |
| remote | include: remote: 'https://example.com/ci.yml' | Any publicly accessible URL |
| template | include: template: 'Auto-DevOps.gitlab-ci.yml' | GitLab built-in templates |
# Include multiple sources include: - local: '/ci/build.yml' # file in same repo - project: 'myorg/ci-templates' # file from another project ref: main file: '/templates/deploy.yml' - template: 'SAST.gitlab-ci.yml' # GitLab built-in security template - remote: 'https://cdn.example.com/ci/lint.yml' # external URL # Using included configuration # The included files can define jobs, stages, variables, etc. # They are merged into the main .gitlab-ci.yml stages: - build - test - security - deploy # Your local jobs here, plus everything from the included files
Security note: when including files from another project with include: project, the user triggering the pipeline must have at least Reporter access to that project. Using a specific SHA hash for ref (rather than a branch name) is recommended for stability and security - branch-based refs can change.
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...
