Child pipeline git init the parent project instead of child project, how to change this behavior

:hugs: Please help fill in this template with all the details to help others help you more efficiently. Use formatting blocks for code, config, logs and ensure to remove sensitive data.

Problem to solve

Describe your question in as much detail as possible:

  • What are you seeing, and how does that differ from what you expect to see?
  • Consider including screenshots, error messages, and/or other helpful visuals

the parent pipeline

cndevops/gitlab-pipeline-examples/parent-project/.gitlab-ci.yml

job_trigger:
  stage: trigger_downstream_pipeline
  inherit:
    variables: false
  trigger:
    strategy: depend
    forward:
      pipeline_variables: true
    include:
      - project: 'cndevops/gitlab-pipeline-examples/child-project'
        ref: 'main'
        file: '.gitlab-ci.yml'

the child pipeline

image:
  name: public.ecr.aws/docker/library/alpine:3

stages:
  - additional_stage

job_additional:
  variables:
    CI_DEBUG_TRACE: "true"
  stage: additional_stage
  rules:
    - if: $CI_PIPELINE_SOURCE == "parent_pipeline"
  script:
    - echo "Running additional tasks"
    - echo "how to pass variable"

the log of child pipeline

# why?, why not git clone child project
cd /builds/cndevops/gitlab-pipeline-examples/parent-project
echo "Running additional tasks"

Versions

Please select whether options apply, and add the version information.

  • Self-managed
  • Self-hosted Runners

Versions

  • GitLab 16.8.2
  • GitLab Runner 15.8.0