From 6fcb0d50fb98db96451a3d0fd83cb9e37822eda3 Mon Sep 17 00:00:00 2001 From: Christian Beikov Date: Tue, 22 Oct 2024 16:21:25 +0200 Subject: [PATCH] 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 543e095cf70396256ebbf2dd9e9d07f80304bebd) --- ci/release/Jenkinsfile | 11 +++++++++-- ci/snapshot-publish.Jenkinsfile | 23 ++++++++++++++--------- gradle/gradle-enterprise.gradle | 11 ++++++++++- settings.gradle | 2 +- 4 files changed, 34 insertions(+), 13 deletions(-) diff --git a/ci/release/Jenkinsfile b/ci/release/Jenkinsfile index 026237cec8..6b6ca9089f 100644 --- a/ci/release/Jenkinsfile +++ b/ci/release/Jenkinsfile @@ -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,7 +164,11 @@ 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 - sh ".release/scripts/publish.sh ${env.SCRIPT_OPTIONS} ${env.PROJECT} ${env.RELEASE_VERSION} ${env.DEVELOPMENT_VERSION} ${env.GIT_BRANCH}" + 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}" + } } } } diff --git a/ci/snapshot-publish.Jenkinsfile b/ci/snapshot-publish.Jenkinsfile index be02d00d2e..02d1ffb5c2 100644 --- a/ci/snapshot-publish.Jenkinsfile +++ b/ci/snapshot-publish.Jenkinsfile @@ -37,15 +37,20 @@ pipeline { string(credentialsId: 'release.gpg.passphrase', variable: 'SIGNING_PASS'), file(credentialsId: 'release.gpg.private-key', variable: 'SIGNING_KEYRING') ]) { - sh '''./gradlew clean publish \ - -PhibernatePublishUsername=$hibernatePublishUsername \ - -PhibernatePublishPassword=$hibernatePublishPassword \ - -Pgradle.publish.key=$hibernatePluginPortalUsername \ - -Pgradle.publish.secret=$hibernatePluginPortalPassword \ - --no-scan \ - -DsigningPassword=$SIGNING_PASS \ - -DsigningKeyFile=$SIGNING_KEYRING \ - ''' + withEnv([ + "DISABLE_REMOTE_GRADLE_CACHE=true" + ]) { + sh '''./gradlew clean publish \ + -PhibernatePublishUsername=$hibernatePublishUsername \ + -PhibernatePublishPassword=$hibernatePublishPassword \ + -Pgradle.publish.key=$hibernatePluginPortalUsername \ + -Pgradle.publish.secret=$hibernatePluginPortalPassword \ + --no-scan \ + --no-build-cache \ + -DsigningPassword=$SIGNING_PASS \ + -DsigningKeyFile=$SIGNING_KEYRING \ + ''' + } } } } diff --git a/gradle/gradle-enterprise.gradle b/gradle/gradle-enterprise.gradle index 700b0618af..107b4d22fd 100644 --- a/gradle/gradle-enterprise.gradle +++ b/gradle/gradle-enterprise.gradle @@ -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 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' diff --git a/settings.gradle b/settings.gradle index 84ff021b9b..46e5a21ef5 100644 --- a/settings.gradle +++ b/settings.gradle @@ -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