Skip to content

Commit a8a11c9

Browse files
author
Dilyan Marinov
committed
ci: slack notification on pipeline failure
Why? In order to set up CI on-call for vdk, visible and reliable notifications are required. The notifications should alert on pipeline failure and provide the necessary information for troubleshooting. What? Call an incoming webhook for a custom slack application on pipeline failure. This sends a message to the corresponding channel. How was this tested? Ran in pipeline and sent notification to debug channel. Note that the env variable for the notification hook will have to be changed after this is merged. https://gitlab.com/vmware-analytics/versatile-data-kit/-/pipelines/914912201 What kind of change is this Feature/non-breaking Signed-off-by: Dilyan Marinov <mdilyan@vmware.com>
1 parent 0918a53 commit a8a11c9

2 files changed

Lines changed: 16 additions & 0 deletions

File tree

.gitlab-ci.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ stages:
2222
- release
2323
- release_image
2424
- end
25+
- notify
2526

2627
build-check-prerequisites:
2728
stage: build
@@ -37,3 +38,13 @@ end:
3738
only:
3839
refs:
3940
- external_pull_requests
41+
42+
notify_failure:
43+
stage: notify
44+
script:
45+
- ./cicd/notify.sh "The pipeline for the $CI_COMMIT_BRANCH branch has failed.\nPlease take the necessary steps to fix it. https://gitlab.com/vmware-analytics/versatile-data-kit/-/pipelines/$CI_PIPELINE_ID" $VDK_SLACK_NOTIFICATION_HOOK
46+
rules:
47+
- if: '$CI_COMMIT_BRANCH != "main"'
48+
when: never
49+
- if: '$CI_COMMIT_BRANCH == "main"'
50+
when: on_failure

cicd/notify.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/bash -e
2+
# Copyright 2021-2023 VMware, Inc.
3+
# SPDX-License-Identifier: Apache-2.0
4+
5+
curl -X POST -H 'Content-type: application/json' --data "{\"text\":\"$1\"}" $2

0 commit comments

Comments
 (0)