6
6
7
7
COMMIT_SHA_SHORT=${DRONE_COMMIT: 0: 8}
8
8
SERVERS=(" oc10" " ocis" )
9
- BUILD_STATUS=" :white_check_mark:** Success** "
9
+ BUILD_STATUS=" ✅ Success"
10
10
TEST_LOGS=" "
11
11
BRANCH_NAME=" ${DRONE_BRANCH} "
12
+ ROOMID=" !rnWsCVUmDHDJbiSPMM:matrix.org"
12
13
13
14
if [ " ${DRONE_BUILD_STATUS} " == " failure" ]; then
14
- BUILD_STATUS=" :x:** Failure** "
15
+ BUILD_STATUS=" ❌️ Failure"
15
16
fi
16
17
17
18
for server in " ${SERVERS[@]} " ; do
@@ -24,7 +25,7 @@ for server in "${SERVERS[@]}"; do
24
25
GUI_STATUS_CODE=$( $CURL " $GUI_LOG " )
25
26
26
27
if [[ " $GUI_STATUS_CODE " == " 200" ]]; then
27
- LOGS+=" : [Squish Report]( $ GUI_LOG) "
28
+ LOGS+=' : <a href= ' " ${ GUI_LOG} " ' >Squish Report</a> '
28
29
fi
29
30
30
31
if [ " ${DRONE_BUILD_STATUS} " == " failure" ]; then
@@ -35,15 +36,15 @@ for server in "${SERVERS[@]}"; do
35
36
STACKTRACE_STATUS_CODE=$( $CURL " $STACKTRACE " )
36
37
37
38
if [[ " $SERVER_STATUS_CODE " == " 200" ]]; then
38
- LOGS+=" \n> [Server log]( $ SERVER_LOG) " # 2 spaces at the end act as line-break
39
+ LOGS+=' <br> <a href= ' " ${ SERVER_LOG} " ' >Server Log</a> <br> '
39
40
fi
40
41
if [[ " $STACKTRACE_STATUS_CODE " == " 200" ]]; then
41
- LOGS+=" \n> [Stacktrace]( $ STACKTRACE) "
42
+ LOGS+=' <br> <a href= ' " ${ STACKTRACE} " ' >Stacktrace</a> '
42
43
fi
43
44
fi
44
45
45
46
if [[ -n " ${LOGS} " ]]; then
46
- LOGS=" \n ${server}${LOGS} "
47
+ LOGS=" ${server}${LOGS} "
47
48
TEST_LOGS+=" ${LOGS} "
48
49
fi
49
50
done
@@ -52,4 +53,37 @@ if [ "${DRONE_BUILD_EVENT}" == "tag" ]; then
52
53
BRANCH_NAME=" Tag: \` ${DRONE_TAG} \` "
53
54
fi
54
55
55
- echo -e " $BUILD_STATUS [${DRONE_REPO} #${COMMIT_SHA_SHORT} ](${DRONE_BUILD_LINK} ) (${BRANCH_NAME} ) by **${DRONE_COMMIT_AUTHOR} ** $TEST_LOGS " > " $1 " /template.md
56
+ # helper functions
57
+ log_error () {
58
+ echo -e " \e[31m$1 \e[0m"
59
+ }
60
+
61
+ log_info () {
62
+ echo -e " \e[37m$1 \e[0m"
63
+ }
64
+
65
+ log_success () {
66
+ echo -e " \e[32m$1 \e[0m"
67
+ }
68
+
69
+ message_html=' <b>' $BUILD_STATUS ' </b> <a href="' ${DRONE_BUILD_LINK} ' ">' ${DRONE_REPO} ' #' $COMMIT_SHA_SHORT ' </a> (' ${BRANCH_NAME} ' ) by <b>' ${DRONE_COMMIT_AUTHOR} ' </b> <br> <b>' " ${TEST_LOGS} " ' </b>'
70
+ message_html=$( echo " $message_html " | sed ' s/\\/\\\\/g' | sed ' s/"/\\"/g' )
71
+
72
+ log_info " Sending report to the element chat..."
73
+
74
+ response=$( curl -s -o /dev/null -X PUT -w " %{http_code}" ' https://matrix.org/_matrix/client/v3/rooms/' $ROOMID ' /send/m.room.message/' $( date +%s) \
75
+ -H " Authorization: Bearer " $MATRIX_TOKEN \
76
+ -H ' Content-Type: application/json' \
77
+ -d ' {
78
+ "msgtype": "m.text",
79
+ "body": "' " $message_html " ' ",
80
+ "format": "org.matrix.custom.html",
81
+ "formatted_body": "' " $message_html " ' "
82
+ }' )
83
+
84
+ if [[ " $response " != " 200" ]]; then
85
+ log_error " ❌ Error: Failed to send notification to element. Expected status code 200, but got $response ."
86
+ exit 1
87
+ fi
88
+
89
+ log_success " ✅ Notification successfully sent to Element chat (ownCloud Infinite Scale Alerts)"
0 commit comments