From 9bd3e9957df608e40f34e25e1a6ee6b6f9d0a787 Mon Sep 17 00:00:00 2001 From: dinesh1patel <74076102+dinesh1patel@users.noreply.github.com> Date: Fri, 12 Sep 2025 12:42:54 +0100 Subject: [PATCH] Update Jenkinsfile_CNP --- Jenkinsfile_CNP | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/Jenkinsfile_CNP b/Jenkinsfile_CNP index 54052a0368..650b7caa1f 100644 --- a/Jenkinsfile_CNP +++ b/Jenkinsfile_CNP @@ -13,6 +13,40 @@ properties( @Library("Infrastructure@DO-NOT-MERGE-FT-TIMEOUT-EXTENSION") +// --------------------------------------------------------- +// 🚦 Stage 0: File change check (SKIP if irrelevant) +// --------------------------------------------------------- +node { + stage('Check Relevant Changes') { + checkout scm + + def changedFiles = sh( + script: "git diff --name-only HEAD~1 HEAD", + returnStdout: true + ).trim().split("\n") + + // ✅ Adjust these patterns to your needs + def triggers = [ + ~/^src\/.*/, // any file under src/ + ~/^app\/.*/, // any file under app/ + ~/^pom\.xml$/ // pom.xml specifically + ] + + def shouldBuild = changedFiles.any { file -> + triggers.any { pattern -> file ==~ pattern } + } + + if (!shouldBuild) { + echo "No relevant changes detected. Skipping pipeline." + currentBuild.result = 'NOT_BUILT' + error("Stopping pipeline early.") + } else { + echo "Relevant changes found: ${changedFiles}" + } + } +} + + def type = "java" def product = "ccd" def component = "data-store-api"