Conversation
There was a problem hiding this comment.
Pull request overview
Adds Jenkins CI support for the monorepo and aligns the Maven build to a Java 21 baseline.
Changes:
- Downgrade Maven compiler/source/target (and
java.version) from 25 to 21 in the rootpom.xml. - Add a new
Jenkinsfilethat conditionally builds/tests selected modules based on path changes.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| pom.xml | Updates project Java/compiler baseline to 21. |
| Jenkinsfile | Introduces a declarative Jenkins pipeline with parallel, per-module conditional builds and JUnit report publishing. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| stage('Monorepo Build & Test') { | ||
| parallel { | ||
|
|
||
| stage('Media Service') { | ||
| when { changeset "media/**" } | ||
| steps { | ||
| echo 'Changes detected in Media Service. Starting Build & Test...' | ||
| sh 'mvn clean test -pl media -am' | ||
| } |
There was a problem hiding this comment.
All stages in the parallel block are gated by when { changeset "<module>/**" }, so changes to root/shared files (e.g., pom.xml, common-library/**, deployment/**, etc.) will skip every branch and the pipeline will report success without running any build/tests (including for this PR, which changes pom.xml). Add a fallback that runs a full build when changes are outside the listed module paths, or expand the when conditions to include shared/root paths and/or a catch-all branch.
| parallel { | ||
|
|
||
| stage('Media Service') { | ||
| when { changeset "media/**" } | ||
| steps { | ||
| echo 'Changes detected in Media Service. Starting Build & Test...' | ||
| sh 'mvn clean test -pl media -am' | ||
| } | ||
| } | ||
|
|
||
| stage('Product Service') { | ||
| when { changeset "product/**" } | ||
| steps { | ||
| echo 'Changes detected in Product Service. Starting Build & Test...' | ||
| sh 'mvn clean test -pl product -am' | ||
| } | ||
| } | ||
|
|
||
| stage('Cart Service') { | ||
| when { changeset "cart/**" } | ||
| steps { | ||
| echo 'Changes detected in Cart Service. Starting Build & Test...' | ||
| sh 'mvn clean test -pl cart -am' | ||
| } |
There was a problem hiding this comment.
Running multiple mvn clean test -pl <module> -am executions in parallel within the same workspace can race on shared module build outputs (e.g., common-library/target) and Maven reactor state, making builds flaky or corrupting artifacts. Consider serializing module builds, or isolating each parallel branch into its own workspace (e.g., ws(...) / separate checkout) and/or avoiding -am in parallel by building shared dependencies once up front.
| sh 'mvn clean test -pl inventory -am' | ||
| } | ||
| } | ||
|
|
There was a problem hiding this comment.
The pipeline only defines conditional builds for a subset of Maven modules (media/product/cart/rating/tax/webhook/promotion/location/inventory), but the root pom.xml lists additional modules (e.g., customer, order, payment, search, storefront-bff, delivery, etc.). As written, changes under those module directories will not trigger any build/test stage. Add stages (or a more generic mechanism) to ensure every module has coverage.
| stage('Other Maven Modules') { | |
| when { | |
| expression { | |
| def coveredModules = [ | |
| 'media', | |
| 'product', | |
| 'cart', | |
| 'rating', | |
| 'tax', | |
| 'webhook', | |
| 'promotion', | |
| 'location', | |
| 'inventory' | |
| ] as Set | |
| return currentBuild.changeSets.any { changeSet -> | |
| changeSet.items.any { item -> | |
| item.affectedFiles.any { file -> | |
| def path = file.path ?: '' | |
| def topLevelDir = path.tokenize('/')[0] | |
| topLevelDir && !coveredModules.contains(topLevelDir) | |
| } | |
| } | |
| } | |
| } | |
| } | |
| steps { | |
| echo 'Changes detected outside the explicitly covered modules. Starting full monorepo Build & Test...' | |
| sh 'mvn clean test' | |
| } | |
| } |
| <java.version>21</java.version> | ||
| <maven.compiler.source>21</maven.compiler.source> | ||
| <maven.compiler.target>21</maven.compiler.target> |
There was a problem hiding this comment.
This changes the project compiler/JDK baseline to Java 21, but the repo still references Java 25 elsewhere (e.g., README.md lists Java 25, and .github/workflows/actions/action.yaml sets up JDK 25). To avoid confusion and ensure consistent builds across CI environments, align the docs and CI toolchains with the intended Java baseline (or document why CI intentionally runs a newer JDK than the compilation target).
| <java.version>21</java.version> | |
| <maven.compiler.source>21</maven.compiler.source> | |
| <maven.compiler.target>21</maven.compiler.target> | |
| <!-- Java 21 is the project compilation baseline; keep compiler settings derived from this single property. --> | |
| <java.version>21</java.version> | |
| <maven.compiler.source>${java.version}</maven.compiler.source> | |
| <maven.compiler.target>${java.version}</maven.compiler.target> |
No description provided.