diff --git a/images/ubuntu/scripts/build/install-bazel.sh b/images/ubuntu/scripts/build/install-bazel.sh index 70fe46f77..c336cea7e 100644 --- a/images/ubuntu/scripts/build/install-bazel.sh +++ b/images/ubuntu/scripts/build/install-bazel.sh @@ -6,11 +6,19 @@ # Source the helpers for use with the script source $HELPER_SCRIPTS/install.sh +source $HELPER_SCRIPTS/etc-environment.sh # Install bazelisk npm install -g @bazel/bazelisk -# run bazelisk once in order to install /usr/local/bin/bazel binary -sudo -u $SUDO_USER bazel version +# Run bazelisk once in order to install /usr/local/bin/bazel binary +bazel version + +# Get the installed Bazel version from bazelisk +BAZEL_VERSION=$(bazel --version | grep "Build label:" | awk '{print $3}') + +# Set USE_BAZEL_FALLBACK_VERSION so that users without .bazelversion +# get the preinstalled version instead of downloading latest +set_etc_environment_variable "USE_BAZEL_FALLBACK_VERSION" "silent:${BAZEL_VERSION}" invoke_tests "Tools" "Bazel"