diff --git a/.drone.star b/.drone.star index 7683d709b25..38d635aa4b2 100644 --- a/.drone.star +++ b/.drone.star @@ -19,7 +19,6 @@ PLUGINS_GIT_ACTION_IMAGE = "plugins/git-action:1" PLUGINS_GITHUB_RELEASE_IMAGE = "plugins/github-release:1" PLUGINS_S3_IMAGE = "plugins/s3:1.5" PLUGINS_S3_CACHE_IMAGE = "plugins/s3-cache:1" -PLUGINS_SLACK_IMAGE = "plugins/slack:1" POSTGRES_ALPINE_IMAGE = "postgres:alpine3.18" SONARSOURCE_SONAR_SCANNER_CLI_IMAGE = "sonarsource/sonar-scanner-cli:11.3" TOOLHIPPIE_CALENS_IMAGE = "toolhippie/calens:20250421" @@ -47,10 +46,6 @@ dir = { config = { "app": "web", - "rocketchat": { - "channel": "builds", - "from_secret": "rocketchat_talk_webhook", - }, "branches": [ "master", "stable-*", @@ -682,19 +677,18 @@ def notify(): "kind": "pipeline", "type": "docker", "name": "chat-notifications", - "clone": { - "disable": True, - }, "steps": [ { - "name": "notify-rocketchat", - "image": PLUGINS_SLACK_IMAGE, - "settings": { - "webhook": { - "from_secret": config["rocketchat"]["from_secret"], + "name": "notify-matrix", + "image": OC_CI_ALPINE_IMAGE, + "environment": { + "MATRIX_TOKEN": { + "from_secret": "matrix_token", }, - "channel": config["rocketchat"]["channel"], }, + "commands": [ + "bash /drone/src/tests/drone/notification.sh", + ], }, ], "trigger": { diff --git a/tests/drone/notifcation.sh b/tests/drone/notifcation.sh new file mode 100644 index 00000000000..372ccfc174e --- /dev/null +++ b/tests/drone/notifcation.sh @@ -0,0 +1,46 @@ +#!/usr/bin/env bash + +set -e + +COMMIT_SHA_SHORT=${DRONE_COMMIT:0:8} +BUILD_STATUS="✅ Success" +ROOMID="!rnWsCVUmDHDJbiSPMM:matrix.org" + +# helper functions +log_error() { + echo -e "\e[31m$1\e[0m" +} + +log_info() { + echo -e "\e[37m$1\e[0m" +} + +log_success() { + echo -e "\e[32m$1\e[0m" +} + +if [[ "$DRONE_BUILD_STATUS" == "failure" ]]; then + BUILD_STATUS="❌️ Failure" +fi + +message_html=''$BUILD_STATUS' '${DRONE_REPO}'#'$COMMIT_SHA_SHORT' ('${DRONE_BRANCH}') by '${DRONE_COMMIT_AUTHOR}'' +message_html=$(echo "$message_html" | sed 's/\\/\\\\/g' | sed 's/"/\\"/g') + +log_info "Sending report to the element chat...." + +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) \ + -H "Authorization: Bearer "$MATRIX_TOKEN \ + -H 'Content-Type: application/json' \ + -d '{ + "msgtype": "m.text", + "body": "'"$message_html"'", + "format": "org.matrix.custom.html", + "formatted_body": "'"$message_html"'" + }') + +if [[ "$response" != "200" ]]; then + log_error "❌ Error: Failed to send notification to element. Expected status code 200, but got $response." + exit 1 +fi + +log_success "✅ Notification successfully sent to Element chat (ownCloud Infinite Scale Alerts)"