From 55ca904570f6969291372f71b6c88c025db4a469 Mon Sep 17 00:00:00 2001 From: lukasz-jarocki-sonarsource Date: Tue, 17 Oct 2023 15:55:51 +0200 Subject: [PATCH] NO-JIRA configuring gradle enterprise to use remote cache --- .cirrus.yml | 4 ++++ settings.gradle | 35 +++++++++++++++++++++++++++++++++-- 2 files changed, 37 insertions(+), 2 deletions(-) diff --git a/.cirrus.yml b/.cirrus.yml index 4f670a16720..78e51a5fbc1 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -26,6 +26,10 @@ env: BRANCH_NIGHTLY: "branch-nightly-build" BRANCH_PATTERN_MAINTENANCE: "branch-.*" BRANCH_PATTERN_PUBLIC: "public_.*" + GRADLE_ENTERPRISE_USERNAME: VAULT[development/team/sonarqube/kv/data/gradle-enterprise data.username] + GRADLE_ENTERPRISE_PASSWORD: VAULT[development/team/sonarqube/kv/data/gradle-enterprise data.password] + GRADLE_ENTERPRISE_URL: VAULT[development/team/sonarqube/kv/data/gradle-enterprise data.url] + GRADLE_ENTERPRISE_KEY: VAULT[development/team/sonarqube/kv/data/gradle-enterprise data.access-key] auto_cancellation: $CIRRUS_BRANCH != $BRANCH_MAIN && $CIRRUS_BRANCH !=~ $BRANCH_PATTERN_MAINTENANCE diff --git a/settings.gradle b/settings.gradle index 895b5c8c677..6d39b61b8e4 100644 --- a/settings.gradle +++ b/settings.gradle @@ -10,6 +10,28 @@ pluginManagement { } } +plugins { + id 'com.gradle.enterprise' version '3.15.1' +} +ext.isCiServer = System.getenv().containsKey("CIRRUS_CI") + +gradleEnterprise { + if (System.getenv().containsKey('GRADLE_ENTERPRISE_URL')) { + server = System.env.'GRADLE_ENTERPRISE_URL' + } + allowUntrustedServer = true // ensure a trusted certificate is configured + + if (isCiServer) { + accessKey = System.env.'GRADLE_ENTERPRISE_KEY' + } + + buildScan { + capture { taskInputFiles = true } + uploadInBackground = false + publishAlwaysIf( isCiServer ) + } +} + rootProject.name = 'sonarqube' include 'plugins:sonar-xoo-plugin' @@ -62,7 +84,6 @@ include 'sonar-ws-generator' include 'test-monitoring' include 'ut-monitoring' -ext.isCiServer = System.getenv().containsKey("CIRRUS_CI") // use Settings.getRootDir() so that it doesn't matter which directory you are executing from File extraSettings = new File(rootDir, 'private/private-settings.gradle') @@ -74,5 +95,15 @@ buildCache { local { enabled = !isCiServer } -} + remote(HttpBuildCache) { + url = System.env.'GRADLE_ENTERPRISE_URL' + '/cache/' + allowUntrustedServer = true + credentials { creds -> + creds.username = System.env.'GRADLE_ENTERPRISE_USERNAME' + creds.password = System.env.'GRADLE_ENTERPRISE_PASSWORD' + } + enabled = true + push = isCiServer + } +} \ No newline at end of file -- 2.39.5