Skip to content
Latchkey

How to Use Dynamic Child Pipelines in GitLab CI

A generator job writes a YAML file and a trigger job runs it, letting one repo emit a pipeline tailored to the diff.

First a job produces a .gitlab-ci.yml artifact, then a downstream trigger job runs it as a child pipeline. This is how monorepos build only changed services.

Generate then trigger

The generate job writes the config as an artifact; the trigger job includes that artifact as a child pipeline.

.gitlab-ci.yml
generate:
  stage: build
  script:
    - ./scripts/generate-pipeline.sh > generated.yml
  artifacts:
    paths:
      - generated.yml

run-children:
  stage: test
  trigger:
    include:
      - artifact: generated.yml
        job: generate
    strategy: depend

Notes

  • strategy: depend makes the parent wait on and inherit the child pipeline status.
  • The generated YAML is a full pipeline definition, so it can declare its own stages, jobs, and rules.
  • Use this to fan out per-service jobs in a monorepo without hand-writing every job.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →