From: Robert Varga Date: Wed, 31 Jan 2018 11:03:28 +0000 (+0100) Subject: upload_to_nexus to return a non-zero exit status X-Git-Tag: v0.11.2~1 X-Git-Url: https://gerrit.linuxfoundation.org/infra/gitweb?a=commitdiff_plain;h=dd02080a04f09de71e96d5946cb8e477257fba96;p=releng%2Flftools.git upload_to_nexus to return a non-zero exit status As it turns out Nexus does not produce a http status code on upload failure and returns back a blank message. This means if we do not detect a successful status from Nexus we need to exit 1 explicity to make sure we return to parallel a proper error status code. JIRA: RELENG-765 Change-Id: Ic221c668bb6cd35befc614159ee8d7220d3f4cfe Co-authored-by: Thanh Ha Signed-off-by: Robert Varga Signed-off-by: Thanh Ha --- diff --git a/shell/deploy b/shell/deploy index c664c36a..b72ae07e 100755 --- a/shell/deploy +++ b/shell/deploy @@ -712,13 +712,14 @@ upload_to_nexus() { echo "Uploading ${file}" local resp - resp=$(curl -s -w "%{http_code}" --netrc --upload-file "$file" "$nexus_repo_url/$file") + resp=$(curl -s -w "\\n\\n%{http_code}" --netrc --upload-file "$file" "$nexus_repo_url/$file") + data=$(echo "$resp" | head -n1) status=$(echo "$resp" | awk 'END {print $NF}') if [ "$status" != "201" ]; then - echo "ERROR: Failed to upload to Nexus. Aborting..." - echo "$resp" - exit "$status" + echo "ERROR: Failed to upload to Nexus with status code $status. Aborting..." + echo "HTTP Response: $data" + exit 1 fi }