I have a multi-module Maven project:
root
SubmoduleA
src
pom.xml
SubmoduleB
src
pom.xml
pom.xml
.gitlab-ci.yml
Is there any way I can trigger a CI pipeline only on SubmoduleA when somebody checks in code that only affects SubmoduleA? For example, someone makes a change in SubmoduleA. Once they commit and push, I want to automatically run build->test->deploy only on SubmoduleA since there were no changes to SubmoduleB.
Is there a way to specify triggers and jobs for specific sub-modules or sub-projects within a repo?
Gitlab has a few options to build your CI/CD:
You can mix them. They are not mutual exclusive.
You are interested in Child/Parent
stages:
- triggers
trigger_a:
stage: triggers
trigger:
include: a/.gitlab-ci.yml
rules:
- changes:
- a/*
trigger_b:
stage: triggers
trigger:
include: b/.gitlab-ci.yml
rules:
- changes:
- b/*
Then you have to include the pipelines for a
and b
projects. You can find more in their documentation
Gitlab can trigger job on catalog change: https://docs.gitlab.com/ee/ci/yaml/#onlychanges
For this solution:
stages:
- modules
- build
moduleB:
stage: modules
script:
- mvn $MAVEN_OPTS -pl projectB clean install --also-make $MAVEN_CLI_OPTS
only:
changes:
- projectB/**
master_job:
stage: build
dependencies:
- projectB
script:
- >
mvn $MAVEN_OPTS -pl projectA clean install $MAVEN_CLI_OPTS
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With