Skip to content

Commit 751d429

Browse files
committed
Diagnostic messages when GitHub API update fails
1 parent 7ceecf9 commit 751d429

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

scripts/common

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,20 @@ 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) TMPFILE=$(mktemp -t curl.XXXXXXXXXX) || exit 1)
19+
20+
local tmpfile=$(mktemp -t curl.XXXXXXXXXX) || exit 1
1821

1922
local curlStatus=$(curl \
20-
-s -o /dev/null -w "%{http_code}" \
23+
-s -o $tmpfile -w "%{http_code}" \
2124
-H "Accept: application/vnd.github.v3+json" \
2225
-H "Authorization: token $GITHUB_OAUTH_TOKEN" \
2326
-d "$json" \
2427
https://api.github.com/repos/scala/scala/statuses/$scala_sha)
2528

2629
[[ "$curlStatus" == "201" ]] || {
27-
echo "Failed to publish GitHub commit status"
30+
echo "Failed to publish GitHub commit status. Got: $curlStatus"
31+
cat $tmpfile
2832
exit 1
2933
}
3034
fi

0 commit comments

Comments
 (0)