From 6d111e83cdbd10067cf0d1b87a596fa313e48f0e Mon Sep 17 00:00:00 2001 From: Victor Martinez Date: Mon, 11 Mar 2024 15:29:08 +0100 Subject: [PATCH] ci(bk): use specialised VMs (#3555) --- .buildkite/README.md | 16 ++++++++++++++-- .buildkite/hooks/prepare-common.sh | 16 ++++++++++------ .buildkite/release.yml | 2 +- .buildkite/snapshot.yml | 2 +- 4 files changed, 26 insertions(+), 10 deletions(-) diff --git a/.buildkite/README.md b/.buildkite/README.md index 0a13f51042..409c434e41 100644 --- a/.buildkite/README.md +++ b/.buildkite/README.md @@ -9,7 +9,7 @@ This is the Buildkite pipeline for releasing the APM Agent Java. ### Pipeline Configuration To view the pipeline and its configuration, click [here](https://buildkite.com/elastic/apm-agent-java-release) or -go to the definition in the `elastic/ci` repository. +go to the definition in `release.yml`. ### Credentials @@ -25,7 +25,7 @@ This is the Buildkite pipeline for the APM Agent Java in charge of the snapshots ### Pipeline Configuration To view the pipeline and its configuration, click [here](https://buildkite.com/elastic/apm-agent-java-snapshot) or -go to the definition in the `elastic/ci` repository. +go to the definition in `snapshot.yml`. ## opentelemetry-benchmark pipeline @@ -35,3 +35,15 @@ This is the Buildkite pipeline for the Opentelemetry Benchmark. To view the pipeline and its configuration, click [here](https://buildkite.com/elastic/apm-agent-java-opentelemetry-benchmark) or go to the definition in `opentelemetry-benchmark.yml`. + +## Buildkite VM runners + +A set of Buildkite VM runners has been created for this repository. The VM runners contain +the required software: +* JDK +* GPG +* Maven dependencies + +If a new version of Java is required, update the `.java-version` file with the latest major. When the changes are merged onto `main,` wait for the following day; that's when the automation will be responsible for recreating the VM with the new Java version. + +If you would like to know more about how it works, please go to https://github.com/elastic/ci-agent-images/tree/main/vm-images/apm-agent-java (**NOTE**: only available for Elastic employees) diff --git a/.buildkite/hooks/prepare-common.sh b/.buildkite/hooks/prepare-common.sh index 50b3d3388e..f5fc876099 100644 --- a/.buildkite/hooks/prepare-common.sh +++ b/.buildkite/hooks/prepare-common.sh @@ -5,19 +5,23 @@ set -euo pipefail JAVA_VERSION=$(cat .java-version | xargs | tr -dc '[:print:]') JAVA_HOME="${HOME}/.java/openjdk${JAVA_VERSION}" export JAVA_HOME -PATH="${JAVA_HOME}/bin:$PATH" +PATH="${JAVA_HOME}/bin:${PATH}" export PATH -# Fallback to install at runtime -if [ ! -d "${JAVA_HOME}" ] ; then +if [ -d "${JAVA_HOME}" ] ; then + echo "--- Skip installing JDK${JAVA_VERSION} :java:" + echo "already available in the Buildkite runner" +else + # Fallback to install at runtime # This should not be the case normally untless the .java-version file has been changed # and the VM Image is not yet available with the latest version. echo "--- Install JDK${JAVA_VERSION} :java:" JAVA_URL=https://jvm-catalog.elastic.co/jdk JAVA_PKG="${JAVA_URL}/latest_openjdk_${JAVA_VERSION}_linux.tar.gz" - curl -L --output /tmp/jdk.tar.gz "$JAVA_PKG" - mkdir -p "$JAVA_HOME" - tar --extract --file /tmp/jdk.tar.gz --directory "$JAVA_HOME" --strip-components 1 + curl -L --output /tmp/jdk.tar.gz "${JAVA_PKG}" + mkdir -p "${JAVA_HOME}" + tar --extract --file /tmp/jdk.tar.gz --directory "${JAVA_HOME}" --strip-components 1 fi +# Validate java is available in the runner. java -version diff --git a/.buildkite/release.yml b/.buildkite/release.yml index b646bf3309..347f35358e 100644 --- a/.buildkite/release.yml +++ b/.buildkite/release.yml @@ -1,6 +1,6 @@ agents: provider: "gcp" - #image: "family/apm-agent-java-ubuntu-2204" + image: "family/apm-agent-java-ubuntu-2204" steps: - label: "Run the release" diff --git a/.buildkite/snapshot.yml b/.buildkite/snapshot.yml index 6421fad588..c5cf1bcb79 100644 --- a/.buildkite/snapshot.yml +++ b/.buildkite/snapshot.yml @@ -1,6 +1,6 @@ agents: provider: "gcp" - #image: "family/apm-agent-java-ubuntu-2204" + image: "family/apm-agent-java-ubuntu-2204" steps: - label: "Run the snapshot"