Skip to content

Commit 1a54b83

Browse files
wilkinsonasbrannen
authored andcommitted
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
1 parent 0cea49f commit 1a54b83

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

gradle/build-cache-settings.gradle

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,19 @@ buildCache {
22
local {
33
enabled = true
44
}
5-
remote(HttpBuildCache) {
6-
enabled = false
5+
if (System.getenv('GRADLE_ENTERPRISE_URL')) {
6+
remote(HttpBuildCache) {
7+
enabled = true
8+
url = "${System.getenv('GRADLE_ENTERPRISE_URL')}/cache/"
9+
def cacheUsername = System.getenv('GRADLE_ENTERPRISE_CACHE_USERNAME')
10+
def cachePassword = System.getenv('GRADLE_ENTERPRISE_CACHE_PASSWORD')
11+
if (cacheUsername && cachePassword) {
12+
push = true
13+
credentials {
14+
username = cacheUsername
15+
password = cachePassword
16+
}
17+
}
18+
}
719
}
820
}

0 commit comments

Comments
 (0)