-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathshared.bash
52 lines (48 loc) · 1.12 KB
/
shared.bash
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
#!/bin/bash
set -exuo pipefail
function commiter_email() {
set +x
git log -n 1 --format='%ae'
set -x
}
function webhook_payload() {
set +x
COMMITER_EMAIL=$(commiter_email)
CURRENT_DATE=$(date)
jq --null-input \
--arg reponame $CIRCLE_PROJECT_REPONAME \
--arg username $CIRCLE_PROJECT_USERNAME \
--arg branch $CIRCLE_BRANCH \
--arg build_num $CIRCLE_BUILD_NUM \
--arg build_url $CIRCLE_BUILD_URL \
--arg author_email $COMMITER_EMAIL \
--arg end_time "$CURRENT_DATE" \
'{
"payload": {
"status": "success",
"outcome":"success",
"username": $username,
"reponame": $reponame,
"branch": $branch,
"build_num": $build_num,
"build_url": $build_url,
"author_email": $author_email,
"steps": [
{
"actions": [
{"end_time": $end_time }
]
}
]
}
}'
set -x
}
function send_webhook() {
set +x
PAYLOAD=$(webhook_payload)
curl -i -X POST https://cc-slack-proxy.herokuapp.com/circle \
-H 'Content-Type: application/json' \
-d "$PAYLOAD"
set -x
}