Skip to content

Commit 26fd934

Browse files
committed
Diagnostic messages when GitHub API update fails
1 parent 7ceecf9 commit 26fd934

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

scripts/common

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,21 @@ function postCommitStatus() {
1515
if [[ "$scala_sha" != "" ]]; then
1616
local jsonTemplate='{ "state": "%s", "target_url": "%s", "description": "%s", "context": "%s"}'
1717
local json=$(printf "$jsonTemplate" "$1" "https://travis-ci.com/scala/scala-dist/builds/$TRAVIS_BUILD_ID" "$1" "travis/scala-dist/$version/$mode")
18+
[[ -z "$GITHUB_OAUTH_TOKEN" ]] && (echo "Missing environment variable GITHUB_OAUTH_TOKEN!"; exit 1)
19+
TMPFILE=$(mktemp -t curl.XXXXXXXXXX)
20+
21+
local tmpfile=$(mktemp -t curl.XXXXXXXXXX) || exit 1
1822

1923
local curlStatus=$(curl \
20-
-s -o /dev/null -w "%{http_code}" \
24+
-s -o $tmpfile -w "%{http_code}" \
2125
-H "Accept: application/vnd.github.v3+json" \
2226
-H "Authorization: token $GITHUB_OAUTH_TOKEN" \
2327
-d "$json" \
2428
https://api.github.com/repos/scala/scala/statuses/$scala_sha)
2529

2630
[[ "$curlStatus" == "201" ]] || {
27-
echo "Failed to publish GitHub commit status"
31+
echo "Failed to publish GitHub commit status. Got: $curlStatus"
32+
cat $tmpfile
2833
exit 1
2934
}
3035
fi

0 commit comments

Comments
 (0)