Pipeline Triggers and Parent-Child Pipelines
What you'll learn: How to trigger downstream pipelines and create parent-child hierarchies for modular, scalable CI/CD architectures.
As your GitLab CI/CD setup grows, managing everything in one .gitlab-ci.yml file becomes unwieldy. Pipeline triggers and parent-child pipelines let you break complex workflows into manageable, reusable pieces—like calling functions from a main program.
Triggering Downstream Pipelines
A pipeline trigger launches another pipeline programmatically. This can be:
- A pipeline in a different project (multi-project pipeline)
- A child pipeline in the same repository (parent-child pattern)
You create triggers using the trigger keyword in a job. Think of it as a "pipeline within a pipeline" orchestration—your main pipeline delegates work to specialized sub-pipelines.
Parent-Child Pipeline Pattern
Parent-child pipelines decompose a monolithic pipeline into focused, smaller pipelines within the same repository. The parent pipeline defines a trigger job that references a separate YAML file:
# .gitlab-ci.yml (parent)
trigger-microservice-tests:
trigger:
include: ci/microservice-tests.yml
strategy: depend
The strategy: depend makes the parent job wait for the child pipeline to complete. Each child pipeline (ci/microservice-tests.yml) is an independent unit with its own stages, jobs, and logic.
Why Use Parent-Child Pipelines?
- Modularity: Separate concerns (backend tests, frontend builds, infrastructure)
- Reusability: Reference child pipelines from multiple parent contexts
- Performance: Children can run in parallel
- Clarity: Easier to debug and maintain smaller pipeline files
Key Takeaway:
Use pipeline triggers and parent-child hierarchies to decompose complex CI/CD workflows into modular, maintainable components that can be independently developed, tested, and orchestrated.