-
Notifications
You must be signed in to change notification settings - Fork 0
/
run.sh
68 lines (58 loc) · 1.65 KB
/
run.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
if [ "$WERCKER_LINGR_NOTIFY_ON" = "failed" ]; then
if [ "$WERCKER_RESULT" = "passed" ]; then
info "Skipping..."
return 0
fi
fi
if [ ! -n "$WERCKER_LINGR_NOTIFY_BOT_ID" ]; then
fail 'Please specify bot-id property.'
fi
info "bot_id: $WERCKER_LINGR_NOTIFY_BOT_ID"
if [ ! -n "$WERCKER_LINGR_NOTIFY_SECRET" ]; then
fail 'Please specify secret property.'
fi
if [ ! -n "$WERCKER_LINGR_NOTIFY_ROOM_ID" ]; then
fail 'Please specify room-id property.'
fi
info "room_id: $WERCKER_LINGR_NOTIFY_ROOM_ID"
openssl=`which openssl`
if [ ! -n "$openssl" ]; then
fail 'OpenSSL command not found.'
fi
bot_verifier=`echo -n $WERCKER_LINGR_NOTIFY_BOT_ID$WERCKER_LINGR_NOTIFY_SECRET | $openssl sha1 | awk '{print $2}'`
if [ "$WERCKER_RESULT" = "passed" ]; then
status="SUCCESS"
else
status="FAILURE"
fi
info "status: $status"
if [ "$CI" = "true" ]; then
step="build"
id=$WERCKER_BUILD_ID
url=$WERCKER_BUILD_URL
elif [ "$DEPLOY" = "true" ]; then
step="deploy"
id=$WERCKER_DEPLOY_ID
url=$WERCKER_DEPLOY_URL
else
step="build"
id=$WERCKER_BUILD_ID
url=$WERCKER_BUILD_URL
fi
info "step: $step"
info "id: $id"
info "url: $url"
result=`curl -G -s \
--data-urlencode "bot=$WERCKER_LINGR_NOTIFY_BOT_ID" \
--data-urlencode "bot_verifier=$bot_verifier" \
--data-urlencode "room=$WERCKER_LINGR_NOTIFY_ROOM_ID" \
--data-urlencode "text=Project $WERCKER_APPLICATION_NAME $step $number, $url : $status" \
http://lingr.com/api/room/say \
--output "$WERCKER_STEP_TEMP/result.txt" \
--write-out "%{http_code}"`
if [ "$result" = "200" ]; then
success "Finished successfully!"
else
echo -e "`cat $WERCKER_STEP_TEMP/result.txt`"
fail "Finished Unsuccessfully."
fi