Skip to content

Commit 03afa43

Browse files
authored
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.
1 parent 4e9b1cf commit 03afa43

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

buildSrc/src/main/groovy/org/elasticsearch/gradle/BuildPlugin.groovy

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ import org.gradle.api.artifacts.ModuleVersionIdentifier
3939
import org.gradle.api.artifacts.ProjectDependency
4040
import org.gradle.api.artifacts.ResolvedArtifact
4141
import org.gradle.api.artifacts.dsl.RepositoryHandler
42+
import org.gradle.api.credentials.HttpHeaderCredentials
4243
import org.gradle.api.execution.TaskExecutionGraph
4344
import org.gradle.api.plugins.JavaBasePlugin
4445
import org.gradle.api.plugins.JavaPlugin
@@ -50,6 +51,7 @@ import org.gradle.api.tasks.bundling.Jar
5051
import org.gradle.api.tasks.compile.GroovyCompile
5152
import org.gradle.api.tasks.compile.JavaCompile
5253
import org.gradle.api.tasks.javadoc.Javadoc
54+
import org.gradle.authentication.http.HttpHeaderAuthentication
5355
import org.gradle.internal.jvm.Jvm
5456
import org.gradle.process.ExecResult
5557
import org.gradle.process.ExecSpec
@@ -570,6 +572,14 @@ class BuildPlugin implements Plugin<Project> {
570572
patternLayout {
571573
artifact "elasticsearch/[module]-[revision](-[classifier]).[ext]"
572574
}
575+
// this header is not a credential but we hack the capability to send this header to avoid polluting our download stats
576+
credentials(HttpHeaderCredentials) {
577+
name = "X-Elastic-No-KPI"
578+
value = "1"
579+
}
580+
authentication {
581+
header(HttpHeaderAuthentication)
582+
}
573583
}
574584
repos.maven {
575585
name "elastic"

0 commit comments

Comments
 (0)