diff --git a/buildSrc/src/main/java/org/elasticsearch/gradle/info/GlobalBuildInfoPlugin.java b/buildSrc/src/main/java/org/elasticsearch/gradle/info/GlobalBuildInfoPlugin.java index d97f5fb2cd320..b59d9806a0bf4 100644 --- a/buildSrc/src/main/java/org/elasticsearch/gradle/info/GlobalBuildInfoPlugin.java +++ b/buildSrc/src/main/java/org/elasticsearch/gradle/info/GlobalBuildInfoPlugin.java @@ -95,6 +95,7 @@ public void apply(Project project) { ext.set("gradleJavaVersion", Jvm.current().getJavaVersion()); ext.set("gitRevision", gitRevision(project.getRootProject().getRootDir())); ext.set("buildDate", ZonedDateTime.now(ZoneOffset.UTC)); + ext.set("isCi", System.getenv("JENKINS_URL") != null); }); } diff --git a/distribution/bwc/build.gradle b/distribution/bwc/build.gradle index 3c41314af5a49..3642efa7746e4 100644 --- a/distribution/bwc/build.gradle +++ b/distribution/bwc/build.gradle @@ -223,8 +223,14 @@ bwcVersions.forPreviousUnreleased { BwcVersions.UnreleasedVersionInfo unreleased Task bwcTask = createRunBwcGradleTask(buildBwcTaskName(projectName)) { inputs.file("${project.buildDir}/refspec") outputs.files(projectArtifact) - outputs.cacheIf { true } + outputs.cacheIf("BWC distribution caching is disabled on 'master' branch") { + // Don't bother caching in 'master' since the BWC branches move too quickly to make this cost worthwhile + project.ext.isCi && System.getenv('GIT_BRANCH')?.endsWith("master") == false + } args ":${projectDir.replace('/', ':')}:assemble" + if (project.gradle.startParameter.buildCacheEnabled) { + args "--build-cache" + } doLast { if (projectArtifact.exists() == false) { throw new InvalidUserDataException("Building ${bwcVersion} didn't generate expected file ${projectArtifact}")