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.
This commit is contained in:
21in7
2026-03-06 23:57:53 +09:00
parent cd9d379bc2
commit 90a72e4c39

6
Jenkinsfile vendored
View File

@@ -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') {