Add opt-in support for remote build cache and pushing to it from CI

This commit provides opt-in enablement of Gradle's remote build
cache. When the GRADLE_ENTERPRISE_URL environment variable is set, its
build cache node will be used as a source of cached output. If both
GRADLE_ENTERPRISE_CACHE_USERNAME and GRADLE_ENTERPRISE_CACHE_PASSWORD
are also set, task output produced by the build will be pushed to the
build cache node for use by subsequent builds.

Closes gh-23883
This commit is contained in:
Andy Wilkinson 2019-10-29 11:46:33 +00:00 committed by Sam Brannen
parent 0cea49fdc0
commit 1a54b83ae1
1 changed files with 14 additions and 2 deletions

View File

@ -2,7 +2,19 @@ buildCache {
local {
enabled = true
}
remote(HttpBuildCache) {
enabled = false
if (System.getenv('GRADLE_ENTERPRISE_URL')) {
remote(HttpBuildCache) {
enabled = true
url = "${System.getenv('GRADLE_ENTERPRISE_URL')}/cache/"
def cacheUsername = System.getenv('GRADLE_ENTERPRISE_CACHE_USERNAME')
def cachePassword = System.getenv('GRADLE_ENTERPRISE_CACHE_PASSWORD')
if (cacheUsername && cachePassword) {
push = true
credentials {
username = cacheUsername
password = cachePassword
}
}
}
}
}