Skip to content

Commit

Permalink
Fallback to merge-base if commit hash is invalid
Browse files Browse the repository at this point in the history
  • Loading branch information
ptankov authored Jan 23, 2025
1 parent fac7588 commit 8cf0d11
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -307,8 +307,14 @@ void checkE2EIgnoreFiles() {
echo "This is the first run. Using merge base as the starting point for the diff."
changedFiles = sh(script: "git diff --name-only \$(git merge-base HEAD origin/$CHANGE_TARGET)", returnStdout: true).trim().split('\n').findAll{it}
} else {
echo "Processing changes since last processed commit: $lastProcessedCommitHash"
changedFiles = sh(script: "git diff --name-only $lastProcessedCommitHash HEAD", returnStdout: true).trim().split('\n').findAll{it}
def commitExists = sh(script: "git cat-file -e $lastProcessedCommitHash 2>/dev/null", returnStatus: true) == 0
if (commitExists) {
echo "Processing changes since last processed commit: $lastProcessedCommitHash"
changedFiles = sh(script: "git diff --name-only $lastProcessedCommitHash HEAD", returnStdout: true).trim().split('\n').findAll{it}
} else {
echo "Commit hash $lastProcessedCommitHash does not exist in the current repository. Using merge base as the starting point for the diff."
changedFiles = sh(script: "git diff --name-only \$(git merge-base HEAD origin/$CHANGE_TARGET)", returnStdout: true).trim().split('\n').findAll{it}
}
}

echo "Excluded files: $excludedFiles"
Expand Down

0 comments on commit 8cf0d11

Please sign in to comment.