-
Notifications
You must be signed in to change notification settings - Fork 0
/
drone-google-chat.sh
executable file
·69 lines (61 loc) · 1.54 KB
/
drone-google-chat.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
69
if [ -z $PLUGIN_IMAGE ]; then
PLUGIN_IMAGE="https://goo.gl/aeDtrS"
fi
if [ -z $PLUGIN_URL ]; then
echo "Missing url"
echo "set variable URL in .drone.yml"
exit 1
fi
if [ -z ${PLUGIN_KEY} ]; then
echo "missing variable KEY"
echo "set variable KEY in .drone.yml"
exit 1
fi
if [ -z ${PLUGIN_TOKEN} ]; then
echo "missing token"
echo "set variable TOKEN in .drone.yml"
exit 1
fi
generate_post_data()
{
cat <<EOF
{
"cards":[
{
"header":{
"title":"#$DRONE_BUILD_NUMBER - $DRONE_REPO_NAME",
"subtitle":"commit: $DRONE_COMMIT_MESSAGE",
"imageUrl":"$PLUGIN_IMAGE"
},
"sections":[
{
"widgets":[
{
"keyValue":{
"topLabel":"Author",
"content":"$DRONE_COMMIT_AUTHOR_NAME"
}
},
{
"keyValue":{
"topLabel":"Branch",
"content":"$DRONE_COMMIT_BRANCH"
}
},
{
"keyValue":{
"topLabel":"Status",
"content":"$DRONE_BUILD_STATUS"
}
}
]
}
]
}
]
}
EOF
}
curl --silent --location --request POST \
--header 'Content-Type: application/json' \
--data "$(generate_post_data)" "${PLUGIN_URL}?key=${PLUGIN_KEY}&token=${PLUGIN_TOKEN}"