Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 0b357e2

Browse files
pks-tEdward Thomson
authored and
Edward Thomson
committed
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.
1 parent 851c51a commit 0b357e2

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

script/coverity.sh

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,24 @@ COVERITY_UNSUPPORTED=1 \
4949
# Upload results
5050
tar czf libgit2.tgz cov-int
5151
SHA=$(git rev-parse --short HEAD)
52-
curl \
52+
53+
HTML="$(curl \
54+
--silent \
55+
--write-out "\n%{http_code}" \
5356
--form token="$COVERITY_TOKEN" \
5457
5558
5659
--form version="$SHA" \
5760
--form description="Travis build" \
58-
https://scan.coverity.com/builds?project=libgit2
61+
https://scan.coverity.com/builds?project=libgit2)"
62+
# Body is everything up to the last line
63+
BODY="$(echo "$HTML" | head -n-1)"
64+
# Status code is the last line
65+
STATUS_CODE="$(echo "$HTML" | tail -n1)"
66+
67+
echo "${BODY}"
68+
69+
if [ "${STATUS_CODE}" != "201" ]; then
70+
echo "Received error code ${STATUS_CODE} from Coverity"
71+
exit 1
72+
fi

0 commit comments

Comments
 (0)