Improve error detection for when SSL invalid 46/5146/2
authorThanh Ha <thanh.ha@linuxfoundation.org>
Mon, 12 Jun 2017 00:37:00 +0000 (20:37 -0400)
committerThanh Ha <thanh.ha@linuxfoundation.org>
Mon, 12 Jun 2017 01:36:24 +0000 (21:36 -0400)
If SSL cert is invalid we don't even reach the Nexus server. So add code
to check that status is 201 before proceeding.

Change-Id: Ic5c8a0ce4177f73e6f753001ee8bbc5fdf02956c
Signed-off-by: Thanh Ha <thanh.ha@linuxfoundation.org>
shell/deploy

index 20dc09b..ac987e0 100755 (executable)
@@ -317,7 +317,7 @@ EOF
 
     local resp
     local status
-    resp=$(curl -s -w "%{http_code}" --netrc -X POST -d "@$FILE_XML" \
+    resp=$(curl -s -w " %{http_code}" --netrc -X POST -d "@$FILE_XML" \
         -H "Content-Type:application/xml" \
         "${nexus_url}/service/local/staging/profiles/${staging_profile_id}/start")
     status=$(echo "$resp" | awk 'END {print $NF}')
@@ -327,6 +327,9 @@ EOF
         msg=$(sed -n -e 's/.*<msg>\(.*\)<\/msg>.*/\1/p' <<< $resp)
         echo "ERROR: $msg"
         exit "$status"
+    elif [ "$status" != "201" ]; then
+        echo "ERROR: Failed with status code $status"
+        exit "$status"
     fi
 
     local staging_repo_id