Skip to content

Commit e3a0cae

Browse files
committed
Check http status when triggering other jobs
1 parent f61be52 commit e3a0cae

File tree

1 file changed

+22
-4
lines changed

1 file changed

+22
-4
lines changed

admin/build.sh

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,26 +60,44 @@ function setupS3() {
6060
echo "setup s3"
6161
}
6262

63+
curlOut="curlOut.txt"
64+
65+
function checkStatus() {
66+
cat $curlOut
67+
rm -f $curlOut
68+
[[ "$1" == "$2" ]] || {
69+
echo "Failed to start smoketest job"
70+
exit 1
71+
}
72+
}
73+
6374
function triggerMsiRelease() {
6475
local jsonTemplate='{ "accountName": "scala", "projectSlug": "scala-dist", "branch": "%s", "commitId": "%s", "environmentVariables": { "mode": "%s", "version": "%s" } }'
6576
local json=$(printf "$jsonTemplate" "$TRAVIS_BRANCH" "$TRAVIS_COMMIT" "$mode" "$version")
66-
curl \
77+
78+
local curlStatus=$(curl \
79+
-s -o $curlOut -w "%{http_code}" \
6780
-H "Authorization: Bearer $APPVEYOR_TOKEN" \
6881
-H "Content-Type: application/json" \
6982
-d "$json" \
70-
https://ci.appveyor.com/api/builds
83+
https://ci.appveyor.com/api/builds)
84+
85+
checkStatus $curlStatus "200"
7186
}
7287

7388
function triggerSmoketest() {
7489
local jsonTemplate='{ "request": { "branch": "%s", "message": "Smoketest %s", "config": { "before_install": "export version=%s" } } }'
7590
local json=$(printf "$jsonTemplate" "$TRAVIS_BRANCH" "$version" "$version")
7691

77-
curl \
92+
local curlStatus=$(curl \
93+
-s -o $curlOut -w "%{http_code}" \
7894
-H "Travis-API-Version: 3" \
7995
-H "Authorization: token $TRAVIS_TOKEN" \
8096
-H "Content-Type: application/json" \
8197
-d "$json" \
82-
https://api.travis-ci.org/repo/scala%2Fscala-dist-smoketest/requests
98+
https://api.travis-ci.org/repo/scala%2Fscala-dist-smoketest/requests)
99+
100+
checkStatus $curlStatus "202"
83101
}
84102

85103
if [[ "$TRAVIS_EVENT_TYPE" == "api" ]]; then

0 commit comments

Comments
 (0)