diff --git a/.buildkite/hooks/pre-command b/.buildkite/hooks/pre-command index 5b42228ea6..b8d23cd6fa 100755 --- a/.buildkite/hooks/pre-command +++ b/.buildkite/hooks/pre-command @@ -14,8 +14,15 @@ if [[ "$BUILDKITE_COMMAND" =~ .*"upload".* ]]; then exit 0 fi +# Run always +source .buildkite/hooks/prepare-common.sh + if [ "$BUILDKITE_PIPELINE_SLUG" == "apm-agent-java-opentelemetry-benchmark" ]; then source .buildkite/hooks/prepare-benchmark.sh + # NOTE: https://github.com/open-telemetry/opentelemetry-java-instrumentation/pull/11323 might + # support .java-version, if so then it might be worthy to read the file. + JAVA_VERSION=21 + source .buildkite/hooks/prepare-common.sh fi if [ "$BUILDKITE_PIPELINE_SLUG" == "apm-agent-java-snapshot" ]; then @@ -25,6 +32,3 @@ fi if [ "$BUILDKITE_PIPELINE_SLUG" == "apm-agent-java-release" ]; then source .buildkite/hooks/prepare-release.sh fi - -# Run always -source .buildkite/hooks/prepare-common.sh diff --git a/.buildkite/hooks/prepare-common.sh b/.buildkite/hooks/prepare-common.sh index 7c04356ecf..7697908c6f 100644 --- a/.buildkite/hooks/prepare-common.sh +++ b/.buildkite/hooks/prepare-common.sh @@ -2,7 +2,9 @@ set -eo pipefail # Configure the java version -JAVA_VERSION=$(cat .java-version | xargs | tr -dc '[:print:]') +if [ -z "$JAVA_VERSION" ] ; then + JAVA_VERSION=$(cat .java-version | xargs | tr -dc '[:print:]') +fi set +u # In case the HOME is not available in the context of the runner. if [ -z "${HOME}" ] ; then