Course contentsShow
← Cloud and Infrastructure
Lesson 1758 of 2,98936. GitLab CI/CDFree lesson

Dynamic Child Pipelines

Create parent-child pipeline relationships that generate and trigger child pipelines dynamically based on conditions.

Dynamic Child Pipelines

You'll learn: How to programmatically generate child pipeline configurations at runtime, enabling conditional multi-pipeline execution based on dynamic conditions.

What Are Dynamic Child Pipelines?

Building on the parent-child pipeline relationship you've learned, dynamic child pipelines take it further: instead of triggering a static .gitlab-ci.yml file, the parent pipeline generates the child's configuration on-the-fly based on runtime conditions, repository state, or external data.

Think of it like a restaurant manager who doesn't just delegate tasks to chefs—they write custom recipes for each chef based on today's available ingredients and customer orders.

How It Works

A parent job executes a script (bash, Python, etc.) that:

  1. Analyzes conditions (changed files, environment variables, API responses)
  2. Generates a new YAML configuration file as an artifact
  3. Triggers a child pipeline using that generated configuration
generate-child:
  stage: prepare
  script:
    - ./scripts/generate-pipeline.sh > child-pipeline.yml
  artifacts:
    paths:
      - child-pipeline.yml

trigger-dynamic-child:
  stage: deploy
  trigger:
    include:
      - artifact: child-pipeline.yml
        job: generate-child
    strategy: depend

Your generate-pipeline.sh might detect changed microservices and only create jobs for those services, or adjust deployment targets based on branch names.

Why Use This Pattern?

  • Efficiency: Only run jobs relevant to current changes
  • Scalability: Handle hundreds of microservices without bloated config files
  • Flexibility: Adjust pipeline structure based on external data or complex logic
  • Modularity: Keep the parent pipeline clean while generating complex child workflows

Key Takeaway: Dynamic child pipelines let you programmatically create pipeline configurations at runtime, enabling intelligent, condition-based workflow generation that adapts to your repository's state.