title: Gitlab CI parent/child pipelines with complex subfolders
body: <p>i have a problem with gitlab (community edition, version 14.1.2) CI with complex pipeline on my monorepo.</p>
  <p>My structure is client/server:</p>
  <blockquote>
  <p>root/<br />
  ---- server/<br />
  -------- lib/<br />
  ----------- libA/<br />
  ----------- libB/<br />
  ----------- libC/<br />
  -------- applications/<br />
  ----------- appA/<br />
  ----------- appB/<br />
  ----------- appC/<br />
  ---- client/<br />
  -------- applications/<br />
  ------------- appA/<br />
  ------------- appB/<br />
  ...</p>
  </blockquote>
  <p>Every folder (root, server, lib, libA, libB, libC etc...) have his own &quot;.gitlab-ci.yml&quot;</p>
  <p><strong>Root</strong> &quot;.gitlab-ci.yml&quot; is:</p>
  <pre><code>stages:
    - build
    - test
  
  build-server:
    stage: build
    trigger:
        include:
            - local: 'server/.gitlab-ci.yml'
    rules:
        - changes:
            - server/**/*
          
  build-client:
    stage: build
    trigger:
        include:
            - local: 'client/.gitlab-ci.yml'
    rules:
        - changes:
            - client/**/*
  </code></pre>
  <p><strong>Server</strong> &quot;.gitlab-ci.yml&quot; is:</p>
  <pre><code>stages:
    - build
    - test
  
  build-lib:
    stage: build
    trigger:
        include:
            - local: 'lib/.gitlab-ci.yml'
    rules:
        - changes:
            - lib/**/*
          
  build-applications:
    stage: build
    trigger:
        include:
            - local: 'applications/.gitlab-ci.yml'
    rules:
        - changes:
            - applications/**/*
  </code></pre>
  <p><strong>lib</strong> &quot;.gitlab-ci.yml&quot; is:</p>
  <pre><code>stages:
    - build
    - test
  
  build-libA:
    stage: build
    script:
       - echo &quot;Execute libA build!&quot; 
    rules:
        - changes:
            - libA/**/*
          
  build-libB:
    stage: build
    script:
       - echo &quot;Execute libB build!&quot; 
    rules:
        - changes:
            - libB/**/*
  </code></pre>
  <p>If i change a file inside libA  only the &quot;.gitlab-ci.yml&quot; of root folder is triggered, other subfolders not detect file changes and not trigger the build.<br />
  The purpose of this configuration is that , for example, when i change a file inside  libA, the pipeline detects the changes and build the libA.<br />
  Somone can help me to resolve? I hope the structure and the problem is clear.  Thanks.</p>
  <p><strong>UPDATE</strong></p>
  <p>I'm using gitlab 14.1.0</p>
  <p>Thanks to DavidC for the answer but with your solution I have not solved my problem, especially with the trigger $CI_PROJECT_PATH seems not to work.</p>
  <p>After some time I finally got a solution (which can be evolved with variables)</p>
  <p><strong>Root</strong> &quot;.gitlab-ci.yml&quot; is:</p>
  <pre><code>stages:
    - build
    - test
  
  build-server:
    stage: build
    trigger:
        include:
            - local: '/server/.gitlab-ci.yml'
    rules:
        - changes:
            - server/**/*
          
  build-client:
    stage: build
    trigger:
        include:
            - local: '/client/.gitlab-ci.yml'
    rules:
        - changes:
            - client/**/*
  </code></pre>
  <p><strong>Server</strong> &quot;.gitlab-ci.yml&quot; is:</p>
  <pre><code>stages:
    - build
    - test
  
  build-lib:
    stage: build
    trigger:
        include:
            - local: '/server/lib/.gitlab-ci.yml'
    rules:
        - changes:
            - server/lib/**/*
          
  build-applications:
    stage: build
    trigger:
        include:
            - local: '/server/applications/.gitlab-ci.yml'
    rules:
        - changes:
            - server/applications/**/*
  </code></pre>
  <p><strong>lib</strong> &quot;.gitlab-ci.yml&quot; is:</p>
  <pre><code>stages:
    - build
    - test
  
  build-libA:
    stage: build
    script:
       - echo &quot;Execute libA build!&quot; 
    rules:
        - changes:
            - server/lib/libA/**/*
          
  build-libB:
    stage: build
    script:
       - echo &quot;Execute libB build!&quot; 
    rules:
        - changes:
            - server/lib/libB/**/*
  </code></pre>
  <p>Pay attention to this line from the gitlab documentation: &quot;Parent and child pipelines were introduced with a maximum depth of one child pipeline level, which was subsequently increased to two. A parent pipeline can activate many child pipelines and these child pipelines can activate their own child pipelines. It is not possible to activate another level of child pipeline. &quot; refer to: <a href="https://docs.gitlab.com/ee/ci/pipelines/parent_child_pipelines.html#nested-child-pipelines" rel="nofollow noreferrer">https://docs.gitlab.com/ee/ci/pipelines/parent_child_pipelines.html#nested-child-pipelines</a></p>
  <p>Thanks for help!</p>