How to trigger a child pipeline when changes to any files in sub directories in a specified branch alone

How to trigger a child pipeline or a stage if there is change in any file/files in the specified directory and its subdirectories ?

In my case the dashboard/bb-api/ has many subdirectories and the pipeline only trigges if there is a change in dashboard/bb-api/ and not if there are changes under dashboard/bb-api/src or its subdirectories.

My ci files are as follows
.gitlab-ci.yml

image: prince11jose/mwapi:runner
cache:
paths:
- /root/.m2/repository/
stages:

  • triggers
    #########################demo######################

Demo B

build_demo_b-api:
stage: triggers
trigger:
include: demo_ci/b-api.yml
rules:
- changes:
- dashboard/bb-api/*

Demo C

build_demo_c-api:
stage: triggers
trigger:
include: demo_ci/c-api.yml
rules:
- changes:
- dashboard/c-api/*

demo_ci/b-api.yml

image: prince11jose/mwapi:runner
cache:
paths:
- /root/.m2/repository/
stages:

  • deepcode
  • build
    #########################demo######################

Demo B

analyze_demo_b-api:
stage: deepcode
script:
- deepcode analyze -p dashboard/b-api/ -txt -sev critical | tee dashboard/b-api/deepcode.txt
artifacts:
paths:
- dashboard/b-api/deepcode.txt
build_demo_b-api:
stage: build
script:
- echo “Building Common”
- ‘mvn -f dashboard -DskipTests=true clean compile install’
- echo “Building b-api”
- ‘mvn -f dashboard/b-api/ -Paws-demo -DskipTests clean compile install’
- cp dashboard/b-api/target/b.war ~/war/demo/b.war
only:
- aws-demo

Should all the subdirectories be specified ?

Found a way to do it proper.

.gitlab-ci.yml

stages:

  • triggers

a-api:

stage: triggers

trigger:

include:

  - local: .ci/demo/.a-api.yml

  - local: .ci/staging/.a-api.yml

  - local: .ci/production/.a-api.yml

strategy: depend

only:

changes:

    - "dashboard/a-api/**/*"

    - "dashboard/a-api/*"