diff --git a/common/.commonfiles.sha b/common/.commonfiles.sha index e4222b6675..a47bb9b5eb 100644 --- a/common/.commonfiles.sha +++ b/common/.commonfiles.sha @@ -1 +1 @@ -882f56284f6082417dace0a8fd667677e41f0841 +227a3c84e7a83be4d2cbe9eb219c4de7979415e2 diff --git a/common/scripts/setup_env.sh b/common/scripts/setup_env.sh index 9a655760e1..385323f3db 100755 --- a/common/scripts/setup_env.sh +++ b/common/scripts/setup_env.sh @@ -95,6 +95,19 @@ IMG="${IMG:-${TOOLS_REGISTRY_PROVIDER}/${PROJECT_ID}/${IMAGE_NAME}:${IMAGE_VERSI CONTAINER_CLI="${CONTAINER_CLI:-docker}" +# Try to use the latest cached image we have. Use at your own risk, may have incompatibly-old versions +if [[ "${LATEST_CACHED_IMAGE:-}" != "" ]]; then + prefix="$(<<<"$IMAGE_VERSION" cut -d- -f1)" + query="${TOOLS_REGISTRY_PROVIDER}/${PROJECT_ID}/${IMAGE_NAME}:${prefix}-*" + latest="$("${CONTAINER_CLI}" images --filter=reference="${query}" --format "{{.CreatedAt|json}}~{{.Repository}}:{{.Tag}}~{{.CreatedSince}}" | sort -n -r | head -n1)" + IMG="$(<<<"$latest" cut -d~ -f2)" + if [[ "${IMG}" == "" ]]; then + echo "Attempted to use LATEST_CACHED_IMAGE, but found no images matching ${query}" >&2 + exit 1 + fi + echo "Using cached image $IMG, created $(<<<"$latest" cut -d~ -f3)" >&2 +fi + ENV_BLOCKLIST="${ENV_BLOCKLIST:-^_\|^PATH=\|^GOPATH=\|^GOROOT=\|^SHELL=\|^EDITOR=\|^TMUX=\|^USER=\|^HOME=\|^PWD=\|^TERM=\|^RUBY_\|^GEM_\|^rvm_\|^SSH=\|^TMPDIR=\|^CC=\|^CXX=\|^MAKEFILE_LIST=}" # Remove functions from the list of exported variables, they mess up with the `env` command.