X-Git-Url: https://gerrit.linuxfoundation.org/infra/gitweb?a=blobdiff_plain;f=shell%2Fopenstack-protect-in-use-images.sh;h=a422cd8786cfd278e9c61968294f8f1e179fde3e;hb=b9eb4581940562effcf67863704a3ec2c47ceca0;hp=a23a4ed81b675edf8149e9de8c6fc478bbe11a72;hpb=d7b9a7cbd308d3d7d0174b5556ef6a53c744cf26;p=releng%2Fglobal-jjb.git diff --git a/shell/openstack-protect-in-use-images.sh b/shell/openstack-protect-in-use-images.sh index a23a4ed8..a422cd87 100644 --- a/shell/openstack-protect-in-use-images.sh +++ b/shell/openstack-protect-in-use-images.sh @@ -22,14 +22,15 @@ os_cloud="${OS_CLOUD:-vex}" set -eu -o pipefail declare -a images -declare -a cfg_images -declare -a yaml_images -readarray -t cfg_images <<< "$(grep -r IMAGE_NAME --include \*.cfg \ - | awk -F'=' '{print $2}' | sort -u)" -readarray -t yaml_images <<< "$(grep -r 'ZZCI - ' --include \*.yaml \ - | awk -F": " '{print $3}' | sed "s:'::;s:'$::;/^$/d" | sort -u)" -mapfile -t images < <(for R in "${cfg_images[@]}" "${yaml_images[@]}" ; do echo "$R" ; done | sort -u) - +images+=("$(grep -r IMAGE_NAME --include \*.cfg jenkins-config \ + | awk -F'=' '{print $2}' | sort -u)") +set +o pipefail # Not all projects have images in YAML files and grep returns non-zero on 0 results +# Ignore SC2179 since we do not want () to result in an empty array item. +#shellcheck disable=SC2179 +images+=("$(grep -r 'ZZCI - ' --include \*.yaml jjb \ + | awk -F": " '{print $3}' | sed -e "s:'::;s:'$::;/^$/d" -e 's/^"//' -e 's/"$//' | sort -u)") +set -o pipefail +readarray -t images <<< "$(for i in "${images[@]}"; do echo "$i"; done | sort -u)" for image in "${images[@]}"; do os_image_protected=$(openstack --os-cloud "$os_cloud" \