My project is using a thirdparty library with git submodule.
Since building the thirdparty library takes too much time, i want to use rules
in gitlab-ci
to control the thirdparty building job.
Here is my .gitlab-ci.yml
stages:
- extern
- package
extern:
stage: extern
variables:
GIT_SUBMODULE_STRATEGY: recursive
script:
- cd extern
- cmake -B build -S . -A x64
- cmake --build build --config Release --target install
rules:
- changes:
- extern/**/*
package:
stage: package
variables:
GIT_SUBMODULE_STRATEGY: none
script:
- echo "building..."
I want make the extern job only excuted if the submodule head changed in my main repository.
But it didn't meet my expectations. The extern job not running as I expected when I change the submodule head in my main repository.
BTW, I'm using GitLab CE 14.6.1
I am assuming CI_COMMIT_BRANCH holds your feature branch name. This Shell script gets all the modified files and search for submodule/external file in the modified files. If it is present in modified files then it builds it.