From 198b82fdf8c71794ec4c22ca07f1fdda0e0d27ab Mon Sep 17 00:00:00 2001 From: Gasper Kojek Date: Thu, 14 Dec 2023 16:43:18 +0100 Subject: [PATCH] Set remote build cache to push only if authenticated --- gradle/gradle-enterprise.gradle | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/gradle/gradle-enterprise.gradle b/gradle/gradle-enterprise.gradle index 18a57df534..7b058c5ae4 100644 --- a/gradle/gradle-enterprise.gradle +++ b/gradle/gradle-enterprise.gradle @@ -25,12 +25,14 @@ buildCache { local.enabled = true remote(HttpBuildCache) { url = 'https://caffeine.gradle-enterprise.cloud/cache/' - push = System.env.CI enabled = true + def cachePassword = settings.ext.find('gradleEnterpriseCachePassword') + ?: System.env.GRADLE_ENTERPRISE_CACHE_PASSWORD + // Check cache password presence to avoid build cache errors on PR builds when not present + push = System.env.CI && cachePassword credentials { username = 'ci' - password = settings.ext.find('gradleEnterpriseCachePassword') - ?: System.env.GRADLE_ENTERPRISE_CACHE_PASSWORD + password = cachePassword } } }