diff options
author | 2020-02-22 20:16:53 -0800 | |
---|---|---|
committer | 2020-02-22 20:16:53 -0800 | |
commit | 57cf063c0dfa6935088e96549d224ff50f56011f (patch) | |
tree | 19f48d5961ea1b7bee5b0f937dc43f1beaaa2ff3 | |
parent | CI: fix job name (diff) |
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.
-rwxr-xr-x | scripts/check_dockerfiles.sh | 11 |
1 files changed, 11 insertions, 0 deletions
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 } |