From 57cf063c0dfa6935088e96549d224ff50f56011f Mon Sep 17 00:00:00 2001 From: MarkKoz Date: Sat, 22 Feb 2020 20:16:53 -0800 Subject: CI: cache the response from Azure API The script may need to use the master commit several times. The easiest way to implement the cache was to just cache the response rather than the commit hash. --- scripts/check_dockerfiles.sh | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'scripts/check_dockerfiles.sh') diff --git a/scripts/check_dockerfiles.sh b/scripts/check_dockerfiles.sh index df6049e..1764017 100755 --- a/scripts/check_dockerfiles.sh +++ b/scripts/check_dockerfiles.sh @@ -13,8 +13,17 @@ repositoryType=${BUILD_REPOSITORY_PROVIDER}&\ repositoryId=${BUILD_REPOSITORY_NAME}&\ api-version=5.0" +declare -A build_cache + get_build() { local branch="${1:?"get_build: argument 1 'branch' is unset"}" + + # Attempt to use cached value + if [[ -v "${build_cache[$branch]}" ]]; then + printf '%s' "${build_cache[$branch]}" + return 0 + fi + local url="${BASE_URL}&branchName=${branch}" printf '%s\n' "Retrieving the latest successful build using ${url}" >&3 @@ -28,6 +37,8 @@ get_build() { then return 1 else + # Cache the response + build_cache["${branch}"]="${response}" printf '%s' "${response}" fi } -- cgit v1.2.3