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 <thanh.ha@linuxfoundation.org>
Signed-off-by: Robert Varga <nite@hq.sk>
Signed-off-by: Thanh Ha <thanh.ha@linuxfoundation.org>
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
}