Skip to content

Commit 1b6be92

Browse files
authored
Add java-matrix and java-fips-matrix Buildkite pipelines (#97253) (#98040)
1 parent 2e2f3ad commit 1b6be92

File tree

7 files changed

+119
-12
lines changed

7 files changed

+119
-12
lines changed

.buildkite/hooks/pre-command

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#!/bin/bash
2+
3+
# On some distros, this directory ends up not readable by the `elasticsearch` user that gets created during tests
4+
# This fixes that
5+
chmod 755 ~
6+
7+
WORKSPACE="$(pwd)"
8+
export WORKSPACE
9+
10+
BUILD_NUMBER="$BUILDKITE_BUILD_NUMBER"
11+
export BUILD_NUMBER
12+
13+
COMPOSE_HTTP_TIMEOUT="120"
14+
export COMPOSE_HTTP_TIMEOUT
15+
16+
JOB_BRANCH="$BUILDKITE_BRANCH"
17+
export JOB_BRANCH
18+
19+
GRADLEW="./gradlew --parallel --scan --build-cache --no-watch-fs -Dorg.elasticsearch.build.cache.url=https://gradle-enterprise.elastic.co/cache/"
20+
export GRADLEW
21+
22+
GRADLEW_BAT="./gradlew.bat --parallel --scan --build-cache --no-watch-fs -Dorg.elasticsearch.build.cache.url=https://gradle-enterprise.elastic.co/cache/"
23+
export GRADLEW_BAT
24+
25+
export $(cat .ci/java-versions.properties | grep '=' | xargs)
26+
27+
JAVA_HOME="$HOME/.java/$ES_BUILD_JAVA"
28+
export JAVA_HOME
29+
30+
JAVA11_HOME="$HOME/.java/java11"
31+
export JAVA11_HOME
32+
33+
JAVA16_HOME="$HOME/.java/openjdk16"
34+
export JAVA16_HOME
35+
36+
if [[ "${ES_RUNTIME_JAVA:-}" ]]; then
37+
RUNTIME_JAVA_HOME=$HOME/.java/$ES_RUNTIME_JAVA
38+
export RUNTIME_JAVA_HOME
39+
fi
40+
41+
GRADLE_BUILD_CACHE_USERNAME=$(vault read -field=username secret/ci/elastic-elasticsearch/migrated/gradle-build-cache)
42+
export GRADLE_BUILD_CACHE_USERNAME
43+
44+
GRADLE_BUILD_CACHE_PASSWORD=$(vault read -field=password secret/ci/elastic-elasticsearch/migrated/gradle-build-cache)
45+
export GRADLE_BUILD_CACHE_PASSWORD

.buildkite/pipelines/periodic.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
steps:
2+
- group: java-fips-matrix
3+
steps:
4+
- label: "{{matrix.ES_RUNTIME_JAVA}} / java-fips-matrix"
5+
command: .ci/scripts/run-gradle.sh -Dbwc.checkout.align=true -Dtests.fips.enabled=true check
6+
timeout_in_minutes: 300
7+
matrix:
8+
setup:
9+
ES_RUNTIME_JAVA:
10+
- java11
11+
- openjdk17
12+
- openjdk18
13+
agents:
14+
provider: gcp
15+
image: family/elasticsearch-ubuntu-2004
16+
machineType: custom-32-98304
17+
buildDirectory: /dev/shm/bk
18+
env:
19+
ES_RUNTIME_JAVA: "{{matrix.ES_RUNTIME_JAVA}}"
20+
- group: java-matrix
21+
steps:
22+
- label: "{{matrix.ES_RUNTIME_JAVA}} / java-matrix"
23+
command: .ci/scripts/run-gradle.sh -Dbwc.checkout.align=true check
24+
timeout_in_minutes: 300
25+
matrix:
26+
setup:
27+
ES_RUNTIME_JAVA:
28+
- java8
29+
- java11
30+
- openjdk16
31+
- zulu8
32+
- zulu11
33+
- corretto11
34+
- corretto8
35+
- adoptopenjdk11
36+
- adoptopenjdk8
37+
- openjdk17
38+
- openjdk18
39+
- openjdk19
40+
- openjdk20
41+
agents:
42+
provider: gcp
43+
image: family/elasticsearch-ubuntu-2004
44+
machineType: custom-32-98304
45+
buildDirectory: /dev/shm/bk
46+
env:
47+
ES_RUNTIME_JAVA: "{{matrix.ES_RUNTIME_JAVA}}"

.ci/init.gradle

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,26 @@ initscript {
1313
boolean USE_ARTIFACTORY = false
1414

1515
if (System.getenv('VAULT_ADDR') == null) {
16+
// When trying to reproduce errors outside of CI, it can be useful to allow this to just return rather than blowing up
17+
if (System.getenv('CI') == null) {
18+
return
19+
}
20+
1621
throw new GradleException("You must set the VAULT_ADDR environment variable to use this init script.")
1722
}
1823

1924
if (System.getenv('VAULT_ROLE_ID') == null && System.getenv('VAULT_SECRET_ID') == null && System.getenv('VAULT_TOKEN') == null) {
25+
// When trying to reproduce errors outside of CI, it can be useful to allow this to just return rather than blowing up
26+
if (System.getenv('CI') == null) {
27+
return
28+
}
29+
2030
throw new GradleException("You must set either the VAULT_ROLE_ID and VAULT_SECRET_ID environment variables, " +
2131
"or the VAULT_TOKEN environment variable to use this init script.")
2232
}
2333

34+
final String vaultPathPrefix = System.getenv('VAULT_ADDR') ==~ /.+vault-ci.+\.dev.*/ ? "secret/ci/elastic-elasticsearch/migrated" : "secret/elasticsearch-ci"
35+
2436
final String vaultToken = System.getenv('VAULT_TOKEN') ?: new Vault(
2537
new VaultConfig()
2638
.address(System.env.VAULT_ADDR)
@@ -44,8 +56,8 @@ final Vault vault = new Vault(
4456

4557
if (USE_ARTIFACTORY) {
4658
final Map<String, String> artifactoryCredentials = vault.logical()
47-
.read("secret/elasticsearch-ci/artifactory.elstc.co")
48-
.getData();
59+
.read("${vaultPathPrefix}/artifactory.elstc.co")
60+
.getData()
4961
logger.info("Using elastic artifactory repos")
5062
Closure configCache = {
5163
return {
@@ -78,10 +90,10 @@ if (USE_ARTIFACTORY) {
7890
}
7991
}
8092

81-
projectsLoaded {
82-
rootProject {
83-
project.pluginManager.withPlugin('com.gradle.build-scan') {
84-
buildScan.server = 'https://gradle-enterprise.elastic.co'
93+
gradle.settingsEvaluated { settings ->
94+
settings.pluginManager.withPlugin("com.gradle.enterprise") {
95+
settings.gradleEnterprise {
96+
server = 'https://gradle-enterprise.elastic.co'
8597
}
8698
}
8799
}
@@ -91,9 +103,9 @@ final String buildCacheUrl = System.getProperty('org.elasticsearch.build.cache.u
91103
final boolean buildCachePush = Boolean.valueOf(System.getProperty('org.elasticsearch.build.cache.push', 'false'))
92104

93105
if (buildCacheUrl) {
94-
final Map<String, String> buildCacheCredentials = vault.logical()
95-
.read("secret/elasticsearch-ci/gradle-build-cache")
96-
.getData();
106+
final Map<String, String> buildCacheCredentials = System.getenv("GRADLE_BUILD_CACHE_USERNAME") ? [:] : vault.logical()
107+
.read("${vaultPathPrefix}/gradle-build-cache")
108+
.getData()
97109
gradle.settingsEvaluated { settings ->
98110
settings.buildCache {
99111
local {
@@ -104,8 +116,8 @@ if (buildCacheUrl) {
104116
url = buildCacheUrl
105117
push = buildCachePush
106118
credentials {
107-
username = buildCacheCredentials.get("username")
108-
password = buildCacheCredentials.get("password")
119+
username = System.getenv("GRADLE_BUILD_CACHE_USERNAME") ?: buildCacheCredentials.get("username")
120+
password = System.getenv("GRADLE_BUILD_CACHE_PASSWORD") ?: buildCacheCredentials.get("password")
109121
}
110122
}
111123
}

.ci/scripts/packaging-test.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ if [ -f "/etc/os-release" ] ; then
4040
# Work around incorrect lintian version
4141
# https://github.com/elastic/elasticsearch/issues/48573
4242
if [ $VERSION_ID == 10 ] ; then
43+
sudo apt-get update -y
4344
sudo apt-get install -y --allow-downgrades lintian=2.15.0
4445
fi
4546
fi

.ci/scripts/run-gradle.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/bin/bash
22
# drop page cache and kernel slab objects on linux
33
[[ -x /usr/local/sbin/drop-caches ]] && sudo /usr/local/sbin/drop-caches
4+
45
rm -Rfv ~/.gradle/init.d
56
mkdir -p ~/.gradle/init.d && cp -v $WORKSPACE/.ci/init.gradle ~/.gradle/init.d
67
if [ "$(uname -m)" = "arm64" ] || [ "$(uname -m)" = "aarch64" ]; then

build-tools-internal/src/main/groovy/elasticsearch.build-scan.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ buildScan {
1919
URL jenkinsUrl = System.getenv('JENKINS_URL') ? new URL(System.getenv('JENKINS_URL')) : null
2020

2121
// Automatically publish scans from Elasticsearch CI
22-
if (jenkinsUrl?.host?.endsWith('elastic.co') || jenkinsUrl?.host?.endsWith('elastic.dev')) {
22+
if (jenkinsUrl?.host?.endsWith('elastic.co') || jenkinsUrl?.host?.endsWith('elastic.dev') || System.getenv('BUILDKITE') == 'true') {
2323
publishAlways()
2424
buildScan.server = 'https://gradle-enterprise.elastic.co'
2525
}

distribution/packages/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,7 @@ Closure commonDebConfig(boolean oss, boolean jdk, String architecture) {
335335
if (oss) {
336336
rename('elasticsearch', 'elasticsearch-oss')
337337
}
338+
fileMode 0644
338339
}
339340
}
340341
}

0 commit comments

Comments
 (0)