Search code examples
gitlabcicd

Trigger Gitlab Pipeline when any file in directory change or any sub directory inside sub directory give directory changes


I am having directory structure as below.

Gitlab pipeline to trigger pipeline when any changes done in abc dir or any sub-directory or any of its sub sub directoty inside it.

So If any changes happened in directory or sub directory or sub of sub directory, Gitlab Trigger pipeline should trigger.

Sample paths:

path: abc/hi/hey/get/ok.txt

path: abc/hi/hello/pli/vet.txt

path: abc/xcd.txt

Current .gitlab-ci.yml

only:
        changes:
            - "abc/*"

I want to check any changes in sub directory and sub sub director of all above paths.I made changes as below.Will this work, or any other changes are required?

New .gitlab-ci.yml

only:
        changes:
            - "abc/**/*"
            - "abc/*"

Ref link- https://docs.gitlab.com/ee/ci/yaml/index.html#onlychanges--exceptchanges

https://forum.gitlab.com/t/how-to-trigger-a-child-pipeline-when-changes-to-any-files-in-sub-directories-in-a-specified-branch-alone/48973/2


Solution

  • If you look at the only/except documentation which you've linked, you'll notice an example on how to trigger a job for changes

    a directory and all its subdirectories, for example path/to/directory/**/*.

    So in your example, you should only need the one line:

    - abc/**/*