-virtualenv "/tmp/v/openstack"
-# shellcheck source=/tmp/v/openstack/bin/activate disable=SC1091
-source "/tmp/v/openstack/bin/activate"
-pip install --upgrade --quiet "pip<10.0.0" setuptools
-pip install --upgrade --quiet python-openstackclient
-pip freeze
+echo "---> update-cloud-images.sh"
-grep -Er '(_system_image:|IMAGE_NAME)' \
---exclude-dir="global-jjb" --exclude-dir="common-packer" \
-| grep ZZCI | awk -F: -e '{print $3}' \
-| grep '\S' | tr -d \'\" | sort -n | uniq \
-| tee "$WORKSPACE/archives/used_image_list.txt"
+grep -Er '(_system_image:|IMAGE_NAME)' \
+ --exclude-dir="global-jjb" --exclude-dir="common-packer" \
+ | grep ZZCI | awk -F: -e '{print $3}' \
+ | grep '\S' | tr -d \'\" | sort -n | uniq \
+ | tee "$WORKSPACE/archives/used_image_list.txt"
image_type="${line% -*}"
# Get the latest images available on the cloud, when $NEW_IMAGE_NAME env
# var is unset and update all images on Jenkins to the latest.
image_type="${line% -*}"
# Get the latest images available on the cloud, when $NEW_IMAGE_NAME env
# var is unset and update all images on Jenkins to the latest.
new_image=${NEW_IMAGE_NAME}
new_image_type="${NEW_IMAGE_NAME% -*}"
# get the $new_image_type to check the image type is being compared
[[ ${new_image_type} =~ ${image_type} ]] && continue
else
new_image=$(openstack image list --long -f value -c Name -c Protected \
new_image=${NEW_IMAGE_NAME}
new_image_type="${NEW_IMAGE_NAME% -*}"
# get the $new_image_type to check the image type is being compared
[[ ${new_image_type} =~ ${image_type} ]] && continue
else
new_image=$(openstack image list --long -f value -c Name -c Protected \
if [[ ${new_image_isotime//[\-\.]/} -gt ${image_in_use_isotime//[\-\.]/} ]]; then
# generate a patch to be submited to Gerrit
if [[ ${new_image_isotime//[\-\.]/} -gt ${image_in_use_isotime//[\-\.]/} ]]; then
# generate a patch to be submited to Gerrit
- echo "Update old image: ${image_in_use} with new image: ${new_image}"
- grep -rlE '(_system_image:|IMAGE_NAME)' | xargs sed -i "s/${image_in_use}/${new_image}/"
+ echo "Update old image: $image_in_use with new image: $new_image"
+ grep -rlE '(_system_image:|IMAGE_NAME)' \
+ | xargs sed -i "s/${image_in_use}/${new_image}/"
# When the script is triggered by upstream packer-merge job
# update only the requested image and break the loop
# When the script is triggered by upstream packer-merge job
# update only the requested image and break the loop