1

According to the documentation, parent-child pipelines should work well with rules - so i'm trying to setup a parent-child pipeline, where the child pipelines only run when something has actually changed in the sub-service. Using the following setup:

main .gitlab-ci.yml:

trigger_service_a:
  trigger:
    include: service_a/.gitlab-ci.yml
  rules:
    - if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
      changes:
        - service_a/*
      when: always

service_a/.gitlab-ci.yml:


workflow:
  rules:
    - if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
      changes:
        - service_a/*
      when: always

service_a:
  script:
    - echo "run"

However, when i push in a merge request without changes inside service_a, the pipeline fails with : trigger_service_a - failed - (downstream pipeline can not be created, Pipeline filtered out by workflow rules.)

Even if i change something in the service_a, i still get the same error.

How can i trigger child-pipelines in branches and merge requests only when something has changed in the sub-service?

1 Answer 1

0

Why are you using the same rules for both parent and child pipelines? You are just triggering the child service if anything changes on files inside the child service directory So, just define rules on child pipeline... It will automatically trigger if any changes happen on service_a/*

1
  • I tried to put this rule only in the child pipeline, but then i get the same error when service_a has no changes . if it has changes, it runs successfully.
    – pulse00
    Apr 12, 2022 at 5:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.