Skip to content

Commit

Permalink
HSEARCH-5223 Check that a CI build does not result in source files up…
Browse files Browse the repository at this point in the history
…dates
  • Loading branch information
marko-bekhta committed Aug 21, 2024
1 parent 8eebf70 commit 2760302
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,9 @@ stage('Default build') {
install \
"} \
"""
// Quick check after the initial build, if we spot the change here, no need to even proceed..
checkNoSourceFilesModifiedOrFail()

dir(helper.configuration.maven.localRepositoryPath) {
stash name:'default-build-result', includes:"org/hibernate/search/**"
stash name:'default-build-cache', includes:".develocity/**"
Expand Down Expand Up @@ -962,6 +965,8 @@ void withMavenWorkspace(Map args, Closure body) {
sh 'ci/docker-cleanup.sh'
tryFinally(body, { // Finally
sh 'ci/docker-cleanup.sh'
}, {
checkNoSourceFilesModifiedOrFail()
})
})
}
Expand Down Expand Up @@ -1155,3 +1160,14 @@ def tryFinally(Closure main, Closure ... finallies) {
throw mainFailure
}
}

void checkNoSourceFilesModifiedOrFail() {
echo 'Checking sources for changes'
// We are ignoring the failsafe-summary.xml as this file may get modified by integration tests running on
// non-default envs and we don't want to change that at the moment:
if (0 == sh(script: "git diff HEAD -- ':!.empty/failsafe-summary.xml' | grep -q '.'", returnStatus: true)) {
throw new IllegalStateException('''Build resulted in source code modifications.
Make sure you have executed the build locally and added all the necessary files to the commit.
''')
}
}

0 comments on commit 2760302

Please sign in to comment.