Don't use the build cache during releases

So that we're extra sure we're not relying on cache left by a previous
Gradle execution.

(cherry picked from commit 543e095cf7)
This commit is contained in:
Christian Beikov 2024-10-22 16:21:25 +02:00
parent 222b1a2b26
commit 6fcb0d50fb
4 changed files with 34 additions and 13 deletions

View File

@ -135,7 +135,10 @@ pipeline {
// update changelog from JIRA
// tags the version
// changes the version to the provided development version
withEnv(["BRANCH=${env.GIT_BRANCH}"]) {
withEnv([
"BRANCH=${env.GIT_BRANCH}",
"DISABLE_REMOTE_GRADLE_CACHE=true"
]) {
sh ".release/scripts/prepare-release.sh ${env.PROJECT} ${env.RELEASE_VERSION} ${env.DEVELOPMENT_VERSION}"
}
}
@ -161,6 +164,9 @@ pipeline {
sshagent(['ed25519.Hibernate-CI.github.com', 'hibernate.filemgmt.jboss.org', 'hibernate-ci.frs.sourceforge.net']) {
// performs documentation upload and Sonatype release
// push to github
withEnv([
"DISABLE_REMOTE_GRADLE_CACHE=true"
]) {
sh ".release/scripts/publish.sh ${env.SCRIPT_OPTIONS} ${env.PROJECT} ${env.RELEASE_VERSION} ${env.DEVELOPMENT_VERSION} ${env.GIT_BRANCH}"
}
}
@ -168,6 +174,7 @@ pipeline {
}
}
}
}
stage('Website release') {
steps {
script {

View File

@ -36,6 +36,9 @@ pipeline {
string(credentialsId: 'ge.hibernate.org-access-key', variable: 'GRADLE_ENTERPRISE_ACCESS_KEY'),
string(credentialsId: 'release.gpg.passphrase', variable: 'SIGNING_PASS'),
file(credentialsId: 'release.gpg.private-key', variable: 'SIGNING_KEYRING')
]) {
withEnv([
"DISABLE_REMOTE_GRADLE_CACHE=true"
]) {
sh '''./gradlew clean publish \
-PhibernatePublishUsername=$hibernatePublishUsername \
@ -43,6 +46,7 @@ pipeline {
-Pgradle.publish.key=$hibernatePluginPortalUsername \
-Pgradle.publish.secret=$hibernatePluginPortalPassword \
--no-scan \
--no-build-cache \
-DsigningPassword=$SIGNING_PASS \
-DsigningKeyFile=$SIGNING_KEYRING \
'''
@ -50,6 +54,7 @@ pipeline {
}
}
}
}
post {
always {
configFileProvider([configFile(fileId: 'job-configuration.yaml', variable: 'JOB_CONFIGURATION_FILE')]) {

View File

@ -11,7 +11,8 @@
ext {
isCiEnvironment = isJenkins() || isGitHubActions() || isGenericCi()
populateRemoteBuildCache = getSetting( "POPULATE_REMOTE" ).isPresent()
populateRemoteBuildCache = isEnabled( "POPULATE_REMOTE" )
useRemoteCache = !isEnabled( "DISABLE_REMOTE_GRADLE_CACHE" )
}
private static boolean isJenkins() {
@ -36,6 +37,14 @@ static java.util.Optional<String> getSetting(String name) {
return java.util.Optional.ofNullable(sysProp);
}
static boolean isEnabled(String setting) {
if ( System.getenv().hasProperty( setting ) ) {
return true
}
return System.hasProperty( setting )
}
gradleEnterprise {
server = 'https://ge.hibernate.org'

View File

@ -287,7 +287,7 @@ buildCache {
enabled = !settings.ext.isCiEnvironment
}
remote(HttpBuildCache) {
enabled = true
enabled = settings.ext.useRemoteCache
// Check access key presence to avoid build cache errors on PR builds when access key is not present
def accessKey = System.getenv("GRADLE_ENTERPRISE_ACCESS_KEY")
push = settings.ext.populateRemoteBuildCache && accessKey