Improve debugging output for deploy nexus-zip cmd 17/8317/5
authorThanh Ha <thanh.ha@linuxfoundation.org>
Tue, 9 Jan 2018 21:38:32 +0000 (16:38 -0500)
committerThanh Ha <thanh.ha@linuxfoundation.org>
Tue, 9 Jan 2018 23:22:01 +0000 (18:22 -0500)
Print out the HTTP Status code as well as the http response from
the server (if any, Nexus doesn't always return any) and the
contents of the zip file on failure.

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

index a983baa..c664c36 100755 (executable)
@@ -685,9 +685,17 @@ deploy_nexus_zip() {
         exit 1
     fi
 
-    echo "Pushing $deploy_zip to $nexus_repo on $nexus_url"
-    curl --netrc --upload-file "$deploy_zip" \
-        "${nexus_url}/service/local/repositories/${nexus_repo}/content-compressed/${nexus_path}"
+    echo "Pushing $deploy_zip to $nexus_repo on $nexus_url to path $nexus_path"
+    resp=$(curl -s -w "\\n\\n%{http_code}" --netrc --upload-file "$deploy_zip" \
+        "${nexus_url}/service/local/repositories/${nexus_repo}/content-compressed/${nexus_path}")
+    status=$(echo "$resp" | awk 'END {print $NF}')
+
+    echo "HTTP status: $status"
+    if [[ "$status" != "20"* ]]; then
+        echo "Failed with: $resp"
+        echo "Zip contains: $(unzip -l "$deploy_zip")"
+        exit "$status"
+    fi
 }
 
 upload_to_nexus() {