Inability to propagate $CI_PROJECT_DIR to child pipelines

Everyone can contribute. Help move this issue forward while earning points, leveling up and collecting rewards.

I have a very simple pipeline consisting of the following two files.

# .gitlab-ci.yml
stages:
  - stage

parent:
  stage: stage
  variables:
    FOO: $CI_PROJECT_DIR
  trigger:
    include: child.yml
# child.yml
child:
  script:
    - echo FOO=$FOO && [ ! -z "$FOO" ]

I expect it to run, but it doesn't. However, if I try to propagate EG. CI_COMMIT_REF_NAME, it suddenly does pass.

You might ask, why do I want to simply propagate this variable when it's readily available in the child job anyway? Well, I've minimized the example to illustrate the issue at hand. My reality however is more complex, where I'm using CI_PROJECT_DIR as part of a bigger string, like FOO: "$CI_PROJECT_DIR/bar. I didn't expect this difference in behavior between the two variables.

Edited by 🤖 GitLab Bot 🤖