A monorepo needs different pipelines per service, only when that service changes.
IntermediateScenarioGitLab CI
Answer
Situation read → Dynamic or child pipelines.
What I'd do →
- Use
rules:changeswithpaths:andcompare_to: refs/heads/main. - For each service trigger a child pipeline:
trigger: include: services/api/.gitlab-ci.yml. - For very dynamic cases, generate YAML in one job and run it via
trigger: include: artifact: ci.yml, job: generate.
Why → Child pipelines keep each service's config small and isolated.
Interview tip → rules:changes on branch pipelines without compare_to always evaluates true on new branches.
More on GitLab CI
How does GitLab CI/CD work at a high level?BeginnerWhat is a GitLab Runner and what executors exist?IntermediateWhat are the types of runners (shared, group, project) and tags?IntermediateHow do `rules:` work and how do they replace `only/except`?IntermediateWhat are workflow rules and how do they prevent duplicate pipelines?AdvancedHow do artifacts and cache differ in GitLab CI?Intermediate