From 40b62ecf0d491b767917458f35c6f687b3c921d2 Mon Sep 17 00:00:00 2001 From: William Young Date: Wed, 30 Mar 2022 20:07:12 +0200 Subject: [PATCH] Add support for running from different namespace --- check_all.sh | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/check_all.sh b/check_all.sh index a5a130a..6bc35dd 100755 --- a/check_all.sh +++ b/check_all.sh @@ -1,19 +1,20 @@ #!/usr/bin/env zsh -buildconfigs=$( oc get buildconfigs -l gitpoller.unstable.tech/type=basic -o json ) +buildconfigs=$( oc get buildconfigs -A -l gitpoller.unstable.tech/type=basic -o json ) jq ".items[]" -c <<< $buildconfigs | while read -r line; do; # jq <<< $line name=$(jq -r ".metadata.name" <<< $line) + namespace=$(jq -r '.metadata.namespace' <<< $line) gituri=$(jq -r ".spec.source.git.uri" <<< $line) gitref=$(jq -r ".spec.source.git.ref // \"main\"" <<< $line) echo "$name = $gituri:$gitref" ref=$(git ls-remote -h "$gituri" "refs/heads/$gitref" | cut -f1) checkref=$(jq -r ".metadata.annotations.\"gitpoller.unstable.tech/lastref\"" <<< $line) if [[ "$ref" != "$checkref" ]]; then - echo "Update needed for $name" - oc start-build "$name" -w && oc annotate --overwrite buildconfig "$name" "gitpoller.unstable.tech/lastref=$ref" + echo "Update needed for $namespace / $name" + oc start-build -n "$namespace" "$name" -w && oc annotate -n "$namespace" --overwrite buildconfig "$name" "gitpoller.unstable.tech/lastref=$ref" else - echo "$name is up to date" + echo "$namespace / $name is up to date" fi done