forked from diyfr/drone_plugin_teams
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathscript.sh
executable file
·45 lines (30 loc) · 1.04 KB
/
script.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
#!/bin/bash
if [ -z "$PLUGIN_WEBHOOK" ]; then
if [ -z "$TEAMS_WEBHOOK" ]; then
echo "Need to set teams_webhook URL"
exit 1
else
WEBHOOK="$TEAMS_WEBHOOK"
fi
else
WEBHOOK="$PLUGIN_WEBHOOK"
fi
if [ "$DRONE_TAG" = "" ]; then
PROJECT_VERSION="$DRONE_COMMIT_SHA"
else
PROJECT_VERSION="$DRONE_TAG"
fi
cp /tmp/basic_card.json /tmp/card_to_send.json
sed -i "s/TEMPLATE_BUILD_URL/${DRONE_BUILD_LINK//\//\\/}/" /tmp/card_to_send.json
sed -i "s/TEMPLATE_PROJECT_NAME/${DRONE_REPO_NAME}/" /tmp/card_to_send.json
sed -i "s/TEMPLATE_PROJECT_VERSION/${PROJECT_VERSION}/" /tmp/card_to_send.json
sed -i "s/TEMPLATE_AUTHOR/${DRONE_COMMIT_AUTHOR}/" /tmp/card_to_send.json
if [ "$DRONE_BUILD_STATUS" = "failure" ]
then
sed -i 's/TEMPLATE_STATUS_ICON/\❌ Failed /' /tmp/card_to_send.json
else
sed -i 's/TEMPLATE_STATUS_ICON/\✔ Succesful /' /tmp/card_to_send.json
fi
sed -i "s/TEMPLATE_TITLE/$PLUGIN_TITLE/" /tmp/card_to_send.json
cat /tmp/card_to_send.json
curl -H "Content-Type: application/json" -X POST -d @/tmp/card_to_send.json "$WEBHOOK"