Gradle Enterprise - remote build cache

This commit is contained in:
Steve Ebersole 2022-02-01 09:40:31 -06:00
parent 95e98c8804
commit 662182adff
4 changed files with 36 additions and 10 deletions

View File

@ -7,7 +7,6 @@
apply plugin: 'base'
buildscript {
dependencies {
constraints {

View File

@ -9,6 +9,8 @@
// Applies details for `https://ge.hibernate.org`
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
apply from: file( 'system-information.gradle' )
gradleEnterprise {
server = 'https://ge.hibernate.org'
@ -17,10 +19,9 @@ gradleEnterprise {
publishAlways()
publishIfAuthenticated()
def isCi = System.getenv("CI") != null || System.getProperty("CI") != null
uploadInBackground = !isCi
uploadInBackground = !settings.ext.isCiEnvironment
if ( isCi ) {
if ( settings.ext.isCiEnvironment ) {
tag "JOB ${System.getenv('JOB_NAME')}"
}
tag "JDK ${JavaVersion.current().toString()}"

View File

@ -0,0 +1,30 @@
ext {
isCiEnvironment = isJenkins() || isGitHubActions() || isGenericCi()
populateRemoteBuildCache = getSetting( "POPULATE_REMOTE" ).isPresent()
}
private static boolean isJenkins() {
return getSetting( "JENKINS_URL" ).isPresent()
}
private static boolean isGitHubActions() {
return getSetting( "GITHUB_ACTIONS" ).isPresent()
}
private static boolean isGenericCi() {
return System.getenv("CI") != null || System.getProperty("CI") != null
}
static java.util.Optional<String> getSetting(String name) {
def envVar = System.getenv(name)
if ( envVar != null ) {
return java.util.Optional.of(envVar);
}
def sysProp = System.getProperty(name)
return java.util.Optional.ofNullable(sysProp);
}

View File

@ -31,17 +31,13 @@ if ( !JavaVersion.current().java11Compatible ) {
}
buildCache {
// duplicated from `gradle-enterprise.gradle` but not sure how to share it...
def isCi = System.getenv("CI") != null || System.getProperty("CI") != null
def populateRemote = System.getenv("POPULATE_REMOTE") != null || System.getProperty("POPULATE_REMOTE") != null
local {
// do not use local build cache for CI jobs, period!
enabled = !isCi
enabled = !settings.ext.isCiEnvironment
}
remote(HttpBuildCache) {
enabled = true
push = populateRemote
push = settings.ext.populateRemoteBuildCache
url = 'https://ge.hibernate.org/cache/'
}
}