-conf_images=("$(grep -r IMAGE_NAME --include \*.cfg jenkins-config \
- | awk -F'=' '{print $2}' | sort -u)")
-# If there are no yaml files the 'grep' will fail, which is OK
-yaml_images=("$(grep -r 'ZZCI - ' --include \*.yaml jjb \
- | awk -F": " '{print $3}' | sed "s:'::;s:'$::;/^$/d" \
- | sort -u)") || true
-readarray -t images <<< "$(for i in "${conf_images[@]}" "${yaml_images[@]}"; do \
- echo "$i"; done | sort)"
+if ! [[ ${#images[@]} -eq 0 ]]; then
+ echo "INFO: There are images to protect defined in jenkins-config."
+else
+ echo "ERROR: No images detected in the jenkins-config dir."
+ exit 1
+fi
+
+if ! [[ ${#jjbimages[@]} -eq 0 ]]; then
+ echo "INFO: There are additional images to protect in the jjb dir."
+ images=("${images[@]}" "${jjbimages[@]}")
+ #dedupe
+ readarray -t images < <(printf '%s\n' "${images[@]}" | sort -u)
+fi
+
+
+echo "INFO: Protecting the following images:"
+for image in "${images[@]}"; do
+ echo "$image"
+done