Skip to content

Commit 7546386

Browse files
committed
Fixed wraith script.
1 parent a01b593 commit 7546386

File tree

1 file changed

+39
-33
lines changed

1 file changed

+39
-33
lines changed

bin/wraith.sh

Lines changed: 39 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,45 @@
11
#!/bin/bash
2-
WRAITH_SLUG=$(node -pe "require('./package.json').wraithSlug")
3-
WRAITH_FAIL=${WRAITH_FAIL:-5}
4-
body="{
5-
'request': {
6-
'travis_event_type': '$TRAVIS_EVENT_TYPE',
7-
'travis_pull_request': '$TRAVIS_PULL_REQUEST',
8-
'travis_pull_request_branch': '$TRAVIS_PULL_REQUEST_BRANCH',
9-
'travis_pull_request_slug': '$TRAVIS_PULL_REQUEST_SLUG',
10-
'travis_repo_slug': '$TRAVIS_PULL_REQUEST_SLUG',
11-
'travis_branch': '$TRAVIS_PULL_REQUEST_BRANCH',
12-
'wraithSlug': $WRAITH_SLUG,
13-
'wraithFail': $WRAITH_FAIL
14-
}
15-
}"
162

17-
echo "Triggering build of $TRAVIS_REPO_SLUG branch $TRAVIS_BRANCH on Travis. Calling Wraith API ..."
3+
if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then
184

19-
output=$(curl -sw "%{http_code}" -X POST \
20-
-H "Content-Type: application/json" \
21-
-H "Accept: application/json" \
22-
-H "Travis-API-Version: 3" \
23-
-d "${body//\'/\"}" \
24-
'http://wraith.themeisle.com?api&travis')
5+
# Sending wraith request.
256

26-
http_code="${output:${#output}-3}"
27-
if [ ${#output} -eq 3 ]; then
28-
body=""
29-
else
30-
body="${output:0:${#output}-3}"
31-
fi
7+
WRAITH_SLUG=$(node -pe "require('./package.json').wraithSlug")
8+
WRAITH_FAIL=${WRAITH_FAIL:-5}
9+
body="{
10+
'request': {
11+
'travis_event_type': '$TRAVIS_EVENT_TYPE',
12+
'travis_pull_request': '$TRAVIS_PULL_REQUEST',
13+
'travis_pull_request_branch': '$TRAVIS_PULL_REQUEST_BRANCH',
14+
'travis_pull_request_slug': '$TRAVIS_PULL_REQUEST_SLUG',
15+
'travis_repo_slug': '$TRAVIS_PULL_REQUEST_SLUG',
16+
'travis_branch': '$TRAVIS_PULL_REQUEST_BRANCH',
17+
'wraithSlug': $WRAITH_SLUG,
18+
'wraithFail': $WRAITH_FAIL
19+
}
20+
}"
21+
22+
echo "Triggering build of $TRAVIS_REPO_SLUG branch $TRAVIS_BRANCH on Travis. Calling Wraith API ..."
23+
24+
output=$(curl -sw "%{http_code}" -X POST \
25+
-H "Content-Type: application/json" \
26+
-H "Accept: application/json" \
27+
-H "Travis-API-Version: 3" \
28+
-d "${body//\'/\"}" \
29+
'http://wraith.themeisle.com?api&travis')
30+
31+
http_code="${output:${#output}-3}"
32+
if [ ${#output} -eq 3 ]; then
33+
body=""
34+
else
35+
body="${output:0:${#output}-3}"
36+
fi
3237

33-
if [ $http_code != 200 ]; then
34-
echo "$output";
35-
exit 1
36-
else
37-
echo "$output";
38-
exit 0
38+
if [ $http_code != 200 ]; then
39+
echo "$output";
40+
exit 1
41+
else
42+
echo "$output";
43+
exit 0
44+
fi
3945
fi

0 commit comments

Comments
 (0)