Add support for running from different namespace
This commit is contained in:
parent
fbb8f69bf5
commit
40b62ecf0d
|
@ -1,19 +1,20 @@
|
||||||
#!/usr/bin/env zsh
|
#!/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 ".items[]" -c <<< $buildconfigs | while read -r line; do;
|
||||||
# jq <<< $line
|
# jq <<< $line
|
||||||
name=$(jq -r ".metadata.name" <<< $line)
|
name=$(jq -r ".metadata.name" <<< $line)
|
||||||
|
namespace=$(jq -r '.metadata.namespace' <<< $line)
|
||||||
gituri=$(jq -r ".spec.source.git.uri" <<< $line)
|
gituri=$(jq -r ".spec.source.git.uri" <<< $line)
|
||||||
gitref=$(jq -r ".spec.source.git.ref // \"main\"" <<< $line)
|
gitref=$(jq -r ".spec.source.git.ref // \"main\"" <<< $line)
|
||||||
echo "$name = $gituri:$gitref"
|
echo "$name = $gituri:$gitref"
|
||||||
ref=$(git ls-remote -h "$gituri" "refs/heads/$gitref" | cut -f1)
|
ref=$(git ls-remote -h "$gituri" "refs/heads/$gitref" | cut -f1)
|
||||||
checkref=$(jq -r ".metadata.annotations.\"gitpoller.unstable.tech/lastref\"" <<< $line)
|
checkref=$(jq -r ".metadata.annotations.\"gitpoller.unstable.tech/lastref\"" <<< $line)
|
||||||
if [[ "$ref" != "$checkref" ]]; then
|
if [[ "$ref" != "$checkref" ]]; then
|
||||||
echo "Update needed for $name"
|
echo "Update needed for $namespace / $name"
|
||||||
oc start-build "$name" -w && oc annotate --overwrite buildconfig "$name" "gitpoller.unstable.tech/lastref=$ref"
|
oc start-build -n "$namespace" "$name" -w && oc annotate -n "$namespace" --overwrite buildconfig "$name" "gitpoller.unstable.tech/lastref=$ref"
|
||||||
else
|
else
|
||||||
echo "$name is up to date"
|
echo "$namespace / $name is up to date"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue