From 4a05e8547f5175aeca9c4b78081c84dbf58de186 Mon Sep 17 00:00:00 2001 From: Bengt Thuree Date: Thu, 28 Nov 2019 00:24:10 +1100 Subject: [PATCH] Fix jenkins-verify-images.sh crash on grep This statement triggers the pipefail grep ^OS_CLOUD= jenkins-config/clouds/openstack/cattle/cloud.cfg $ echo $? 1 ISSUE-ID: IT-18352 Signed-off-by: Bengt Thuree Change-Id: Id71b3b664f5dca98bc4d784b86e8d68cec7fca9e --- .../notes/grep_OS_CLOUD_failure-2c81e313686816c7.yaml | 4 ++++ shell/jenkins-verify-images.sh | 16 +++++++--------- 2 files changed, 11 insertions(+), 9 deletions(-) create mode 100644 releasenotes/notes/grep_OS_CLOUD_failure-2c81e313686816c7.yaml diff --git a/releasenotes/notes/grep_OS_CLOUD_failure-2c81e313686816c7.yaml b/releasenotes/notes/grep_OS_CLOUD_failure-2c81e313686816c7.yaml new file mode 100644 index 00000000..6d8a52b6 --- /dev/null +++ b/releasenotes/notes/grep_OS_CLOUD_failure-2c81e313686816c7.yaml @@ -0,0 +1,4 @@ +--- +fixes: + - | + Fix grep OS_CLOUD terminates jenkins-verify-images.sh if not found. diff --git a/shell/jenkins-verify-images.sh b/shell/jenkins-verify-images.sh index e4e9e708..a27efd83 100755 --- a/shell/jenkins-verify-images.sh +++ b/shell/jenkins-verify-images.sh @@ -39,16 +39,14 @@ verify_images() done } +echo "Verifying that cloud has a master configuration file" for cloud in jenkins-config/clouds/openstack/*; do - echo "Verifying that cloud has a master configuration file" - # Verify that we have a cloud config file - if [ -f "$cloud/cloud.cfg" ]; then - # Get the OS_CLOUD variable from cloud config and export it - os_cloud=$(grep ^OS_CLOUD= "$cloud/cloud.cfg" | cut -d'=' -f2) - OS_CLOUD="${os_cloud:-vex}" - export OS_CLOUD - - verify_images "$cloud" + if [[ -f $cloud/cloud.cfg ]]; then + # Get the OS_CLOUD variable from cloud config + if ! os_cloud=$(egrep "^OS_CLOUD=" "$cloud/cloud.cfg" | cut -d'=' -f2); then + os_cloud="vex" + fi + OS_CLOUD=$os_cloud verify_images "$cloud" else echo "ERROR: No cloud.cfg for $cloud" error=true -- 2.16.6