From 90a72e4c39c74b9ded8c34ab39931e0916c97a10 Mon Sep 17 00:00:00 2001 From: 21in7 Date: Fri, 6 Mar 2026 23:57:53 +0900 Subject: [PATCH] fix: improve change detection logic in Jenkinsfile - Updated the change detection script to compare the current commit with the previous successful build, falling back to HEAD~5 if no previous commit exists. - Enhanced logging to indicate the base commit used for comparison. --- Jenkinsfile | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index f271307..36967ad 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -37,7 +37,11 @@ pipeline { stage('Detect Changes') { steps { script { - def changes = sh(script: 'git diff --name-only HEAD~1 || echo "ALL"', returnStdout: true).trim() + // 이전 성공 빌드 커밋과 비교 (없으면 HEAD~5 fallback) + def baseCommit = env.GIT_PREVIOUS_SUCCESSFUL_COMMIT ?: sh(script: 'git rev-parse HEAD~5 2>/dev/null || echo ""', returnStdout: true).trim() + def diffCmd = baseCommit ? "git diff --name-only ${baseCommit}..HEAD" : 'git diff --name-only HEAD~1' + def changes = sh(script: "${diffCmd} || echo \"ALL\"", returnStdout: true).trim() + echo "Base commit: ${baseCommit ?: 'HEAD~1 (fallback)'}" echo "Changed files:\n${changes}" if (changes == 'ALL') {