Skip to content

Commit

Permalink
help with knowing what's the reason it's not installed
Browse files Browse the repository at this point in the history
  • Loading branch information
v1v committed Mar 11, 2024
1 parent 55f0427 commit 76924dc
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions .buildkite/hooks/prepare-common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 76924dc

Please sign in to comment.