Gitlab CI trigger: with rules: fails with "downstream pipeline can not be created..."

,

I’m currently having a hard time understanding how triggers: work if they are combines with rules:

Example:

.gitlab-ci.yml

parent:
  trigger:
    include: child.gitlab.yml
    strategy: depend
    forward:
      pipeline_variables: true
  rules:
    - if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH || $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == $CI_DEFAULT_BRANCH'

child.gitlab.yml

stages:
  - debug

print_env:
  stage: debug
  script:
    - env
# It works if you add this rule (or any other rule that evaluate to true). Doesn't make sense to me
# rules:
#   - if: $CI

What I expect:
That it creates a child pipeline which runs the print_env jobs.

What actually happens:
The parent jobs failes with: parent - failed (downstream pipeline can not be created, Pipeline will not run for the selected trigger. The rules configuration prevent any jobs from being added to the pipeline.)

What also makes no sense to me: If i add a rule to print_env that gets evaluated to true (e. g. if: $CI) it actually works.

Is that normal behaviour and if yes, is it documented somewhere ? To me that really looks like a bug.

1 Like