From 5ab5a0a52961c6761cb5353f1a23653bf1800f28 Mon Sep 17 00:00:00 2001 From: Jason Tedor Date: Sat, 9 Feb 2019 09:22:43 -0500 Subject: [PATCH] Avoid polluting download stats on builds (#38660) Recently we changed where we source released artifacts for usage in backwards compatibility tests. We now source these from artifacts.elastic.co. To avoid polluting the download stats from builds, we want to add the X-Elastic-No-KPI header to requests from artifacts.elastic.co. To do this, we hack the Ivy feature of custom HTTP header credentials and specify our desired headers. --- .../groovy/org/elasticsearch/gradle/BuildPlugin.groovy | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/buildSrc/src/main/groovy/org/elasticsearch/gradle/BuildPlugin.groovy b/buildSrc/src/main/groovy/org/elasticsearch/gradle/BuildPlugin.groovy index f240ebb52c8..4f88a9791eb 100644 --- a/buildSrc/src/main/groovy/org/elasticsearch/gradle/BuildPlugin.groovy +++ b/buildSrc/src/main/groovy/org/elasticsearch/gradle/BuildPlugin.groovy @@ -39,6 +39,7 @@ import org.gradle.api.artifacts.ModuleVersionIdentifier import org.gradle.api.artifacts.ProjectDependency import org.gradle.api.artifacts.ResolvedArtifact import org.gradle.api.artifacts.dsl.RepositoryHandler +import org.gradle.api.credentials.HttpHeaderCredentials import org.gradle.api.execution.TaskExecutionGraph import org.gradle.api.plugins.JavaBasePlugin import org.gradle.api.plugins.JavaPlugin @@ -50,6 +51,7 @@ import org.gradle.api.tasks.bundling.Jar import org.gradle.api.tasks.compile.GroovyCompile import org.gradle.api.tasks.compile.JavaCompile import org.gradle.api.tasks.javadoc.Javadoc +import org.gradle.authentication.http.HttpHeaderAuthentication import org.gradle.internal.jvm.Jvm import org.gradle.process.ExecResult import org.gradle.process.ExecSpec @@ -570,6 +572,14 @@ class BuildPlugin implements Plugin { patternLayout { artifact "elasticsearch/[module]-[revision](-[classifier]).[ext]" } + // this header is not a credential but we hack the capability to send this header to avoid polluting our download stats + credentials(HttpHeaderCredentials) { + name = "X-Elastic-No-KPI" + value = "1" + } + authentication { + header(HttpHeaderAuthentication) + } } repos.maven { name "elastic"