Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .buildkite/pipelines/java-ea-check-new-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
steps:
- command: .buildkite/scripts/trigger-if-java-ea-new-build.sh
env:
RECENT_TIME_WINDOW: "24" # time window to consider a build as new in hours
agents:
image: "docker.elastic.co/ci-agent-images/eck-region/buildkite-agent:1.5"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thats the version of that image we use in other places. We should look into automating the updates via renovate

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See #134122 as follow up on this

memory: "4G"
95 changes: 95 additions & 0 deletions .buildkite/scripts/trigger-if-java-ea-new-build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
#
# Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
# or more contributor license agreements. Licensed under the "Elastic License
# 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
# Public License v 1"; you may not use this file except in compliance with, at
# your election, the "Elastic License 2.0", the "GNU Affero General Public
# License v3.0 only", or the "Server Side Public License, v 1".
#

#!/bin/bash

# Allow overriding the time window (in hours) to check for new builds, defaults to 24
RECENT_TIME_WINDOW=${RECENT_TIME_WINDOW:-24}

# Extract current JDK major version from bundled_jdk in version.properties
CURRENT_JDK=$(grep "^bundled_jdk =" build-tools-internal/version.properties | cut -d'=' -f2 | tr -d ' ' | cut -d'.' -f1)
TARGET_JDK=$((CURRENT_JDK + 1))

echo "Current JDK major version: $CURRENT_JDK"
echo "Target JDK major version: $TARGET_JDK"

# Query Elasticsearch JDK archive for available JDKs
JDK_ARCHIVE_URL="https://builds.es-jdk-archive.com/jdks/openjdk/recent.json"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are using the recent.json here and not the latest.json as latest.json does not seem to have RCs in them. cc @brianseeders

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are currently parsing https://jdk.java.net/<major> page which is less convenient (it's not a JSON), but it shows different dates. E.g. JDK 25 build 36 is Aug 14th, while in JDK archive the latest archived_at is 2025-08-27T15:45:03.262Z. SHAs are the same. Why this discrepancy? The timestamp in JDK archive seems late. Were there multiple archive events for the same build? Should we switch to JDK archive to align?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the date in the archive reflects when we archived it. Usually it should be within 24h as we usually check once per day. The timestamp for the rc36 is late as we added support for RC versions after 36 was already available. therefore the gap. I don't see too much need for you to migrate other than the json api and the option to resolve older RCs / EAs and not just the newest available.

echo "Querying JDK archive: $JDK_ARCHIVE_URL"

# Fetch JDK info and filter for target major version
JDK_DATA=$(curl -s "$JDK_ARCHIVE_URL")

if [[ -z "$JDK_DATA" ]]; then
echo "Failed to fetch JDK data from archive"
exit 1
fi

# Find the latest build for the target JDK version
LATEST_BUILD=$(echo "$JDK_DATA" | jq -r --arg target "$TARGET_JDK" '
.majors[$target].builds |
sort_by(.archived_at) |
last'
)

if [[ "$LATEST_BUILD" == "null" || -z "$LATEST_BUILD" ]]; then
echo "No builds found for JDK $TARGET_JDK"
exit 1
fi

# Extract timestamp and JDK identifier
TIMESTAMP=$(echo "$LATEST_BUILD" | jq -r '.archived_at')
JDK_IDENTIFIER=$(echo "$LATEST_BUILD" | jq -r '.id')

echo "Latest JDK ${TARGET_JDK} build from ES archive:"
echo " Timestamp: $TIMESTAMP"
echo " JDK Identifier: $JDK_IDENTIFIER"

# Set variables for use in the pipeline trigger
jdkbuild="$JDK_IDENTIFIER"
jdk_timestamp="$TIMESTAMP"

# Check if timestamp is within last 24 hours
CURRENT_TIME=$(date +%s)
BUILD_TIME=$(date -d "$TIMESTAMP" +%s 2>/dev/null || date -j -f "%Y-%m-%dT%H:%M:%S" "${TIMESTAMP%Z}" +%s 2>/dev/null || echo "0")

if [[ "$BUILD_TIME" == "0" ]]; then
echo "Failed to parse timestamp: $TIMESTAMP"
SHOULD_TRIGGER="false"
else
TIME_DIFF=$((CURRENT_TIME - BUILD_TIME))
TIME_WINDOW=$((RECENT_TIME_WINDOW * 60 * 60))

if [[ $TIME_DIFF -lt $TIME_WINDOW ]]; then
echo "Build is recent (less than ${RECENT_TIME_WINDOW}h old)"
SHOULD_TRIGGER="true"
else
echo "Build is older than ${RECENT_TIME_WINDOW} hours"
SHOULD_TRIGGER="false"
fi
fi

echo "SHOULD_TRIGGER: $SHOULD_TRIGGER"


if [[ "$SHOULD_TRIGGER" == "true" ]]; then
EFFECTIVE_START_DATE=$(date -u -d "@$BUILD_TIME" +"%Y-%m-%dT%H:%M:%SZ" 2>/dev/null || date -u -r "$BUILD_TIME" +"%Y-%m-%dT%H:%M:%SZ" 2>/dev/null || echo "")
echo "Triggering performance-esbench-jdk for new jdk build $JDK_IDENTIFIER"
cat << EOF | buildkite-agent pipeline upload
steps:
- trigger: elasticsearch-performance-esbench-jdk
label: Triggering performance-esbench-jdk for new jdk build $JDK_IDENTIFIER
async: true
build:
branch: "$BUILDKITE_BRANCH"
env:
EFFECTIVE_START_DATE: "$EFFECTIVE_START_DATE"
EXECUTION_MODE: "start-run"
EOF
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can test this locally by running:

.buildkite/scripts/trigger-if-java-ea-new-build.sh
Current JDK major version: 24
Target JDK major version: 25
Querying JDK archive: https://builds.es-jdk-archive.com/jdks/openjdk/recent.json
Latest JDK 25 build from ES archive:
  Timestamp: 2025-08-27T15:45:03.262Z
  JDK Identifier: openjdk-25-rc+36
Build is older than 24 hours
SHOULD_TRIGGER: false

or with overriding the 24h testing window:

RECENT_TIME_WINDOW=200 bash .buildkite/scripts/trigger-if-new-java-ea-build.sh
Current JDK major version: 24
Target JDK major version: 25
Querying JDK archive: https://builds.es-jdk-archive.com/jdks/openjdk/recent.json
Latest JDK 25 build from ES archive:
  Timestamp: 2025-08-27T15:45:03.262Z
  JDK Identifier: openjdk-25-rc+36
Build is recent (less than 200h old)
SHOULD_TRIGGER: true
Triggering performance-esbench-jdk for new jdk build openjdk-25-rc+36

fi
40 changes: 39 additions & 1 deletion catalog-info.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,45 @@ spec:
cronline: "0 4 * * * America/New_York"
message: "Run java EA tests 1x per day"
---

# yaml-language-server: $schema=https://gist.githubusercontent.com/elasticmachine/988b80dae436cafea07d9a4a460a011d/raw/e57ee3bed7a6f73077a3f55a38e76e40ec87a7cf/rre.schema.json
apiVersion: backstage.io/v1alpha1
kind: Resource
metadata:
name: buildkite-pipeline-elasticsearch-java-ea-check-new-build
description: Check for new jdk ea build and trigger downstream jobs
links:
- title: Pipeline
url: https://buildkite.com/elastic/elasticsearch-java-ea-check-new-build
spec:
type: buildkite-pipeline
system: buildkite
owner: group:elasticsearch-team
implementation:
apiVersion: buildkite.elastic.dev/v1
kind: Pipeline
metadata:
description: ":java: Check for new pre release jdk build and trigger downstream jobs"
name: elasticsearch / java-ea / check-new-build
spec:
repository: elastic/elasticsearch
pipeline_file: .buildkite/pipelines/java-ea-check-new-build.yml
branch_configuration: main
teams:
elasticsearch-team: {}
ml-core: {}
everyone:
access_level: BUILD_AND_READ
provider_settings:
build_branches: false
build_pull_requests: false
publish_commit_status: false
trigger_mode: none
schedules:
Periodically on main:
branch: main
cronline: "0 6 * * * UTC"
message: "Check for new java pre release build 1x per day"
---
# yaml-language-server: $schema=https://gist.githubusercontent.com/elasticmachine/988b80dae436cafea07d9a4a460a011d/raw/e57ee3bed7a6f73077a3f55a38e76e40ec87a7cf/rre.schema.json
apiVersion: backstage.io/v1alpha1
kind: Resource
Expand Down