summaryrefslogtreecommitdiff
path: root/script
diff options
context:
space:
mode:
authorPatrick Steinhardt <ps@pks.im>2016-03-02 01:50:34 +0100
committerPatrick Steinhardt <ps@pks.im>2016-03-11 13:31:12 +0100
commit2615d0d6949c9f52e988ab649f10cf7a80c45186 (patch)
tree79b2c64b40841cd135ab1ce34e585e279593b624 /script
parent1a8c11f44356e7b1379b3bced5bbf86fce576c28 (diff)
downloadlibgit2-2615d0d6949c9f52e988ab649f10cf7a80c45186.tar.gz
coverity: report errors when uploading tarball
Curl by default does not report errors by setting the error code. As the upload can fail through several conditions (e.g. the rate limit, leading to unauthorized access) we should indicate this information in Travis CI. To improve upon the behavior, use `--write-out=%{http_code}` to write out the HTTP code in addition to the received body and return an error if the code does not equal 201.
Diffstat (limited to 'script')
-rwxr-xr-xscript/coverity.sh18
1 files changed, 16 insertions, 2 deletions
diff --git a/script/coverity.sh b/script/coverity.sh
index 8c826892f..7fe9eb4c7 100755
--- a/script/coverity.sh
+++ b/script/coverity.sh
@@ -49,10 +49,24 @@ COVERITY_UNSUPPORTED=1 \
# Upload results
tar czf libgit2.tgz cov-int
SHA=$(git rev-parse --short HEAD)
-curl \
+
+HTML="$(curl \
+ --silent \
+ --write-out "\n%{http_code}" \
--form token="$COVERITY_TOKEN" \
--form email=bs@github.com \
--form file=@libgit2.tgz \
--form version="$SHA" \
--form description="Travis build" \
- https://scan.coverity.com/builds?project=libgit2
+ https://scan.coverity.com/builds?project=libgit2)"
+# Body is everything up to the last line
+BODY="$(echo "$HTML" | head -n-1)"
+# Status code is the last line
+STATUS_CODE="$(echo "$HTML" | tail -n1)"
+
+echo "${BODY}"
+
+if [ "${STATUS_CODE}" != "201" ]; then
+ echo "Received error code ${STATUS_CODE} from Coverity"
+ exit 1
+fi