File tree Expand file tree Collapse file tree 3 files changed +38
-19
lines changed
Expand file tree Collapse file tree 3 files changed +38
-19
lines changed Original file line number Diff line number Diff line change @@ -143,7 +143,7 @@ var_21: &slack_notify_on_failure
143143 run :
144144 name : " Notifying team about job failure"
145145 when : on_fail
146- command : ./scripts/circleci/notify-slack-job-failure.sh
146+ command : node ./scripts/circleci/notify-slack-job-failure.js
147147
148148# -----------------------------
149149# Container version of CircleCI
@@ -582,7 +582,8 @@ jobs:
582582 - run :
583583 name : Running size integration tests (failures are reported in Slack only).
584584 command : |
585- yarn integration-tests:size-test || ./scripts/circleci/notify-slack-job-failure.sh
585+ # If the size integration tests fail, report the failure to a dedicated #components-ci-size-tracking Slack channel.
586+ yarn integration-tests:size-test || node ./scripts/circleci/notify-slack-job-failure.js components-ci-size-tracking
586587 - run : yarn integration-tests:view-engine
587588 - *slack_notify_on_failure
588589
Original file line number Diff line number Diff line change 1+ #!/usr/bin/env node
2+
3+ /**
4+ * Script that notifies Slack about the currently failing job. This script
5+ * will be a noop when running for forked builds (i.e. PRs).
6+ */
7+
8+ if ( process . env . CIRCLE_PR_NUMBER ) {
9+ console . info ( 'Skipping notifications for pull requests.' ) ;
10+ process . exit ( 0 ) ;
11+ }
12+
13+ const { echo, set} = require ( 'shelljs' ) ;
14+ const {
15+ CIRCLE_JOB : jobName ,
16+ CIRCLE_BRANCH : branchName ,
17+ CIRCLE_BUILD_URL : jobUrl ,
18+ SLACK_COMPONENTS_CI_FAILURES_WEBHOOK_URL : webhookUrl ,
19+ } = process . env ;
20+
21+ const text = `\`${ jobName } \` failed in branch: ${ branchName } : ${ jobUrl } ` ;
22+ const payload = { text} ;
23+ const [ channelName ] = process . argv . slice ( 2 ) ;
24+
25+ set ( '-e' ) ;
26+
27+ // If an explicit channel has been specified, override the default
28+ // webhook channel to the specified one.
29+ if ( channelName !== undefined ) {
30+ payload . channel = channelName ;
31+ }
32+
33+ echo ( JSON . stringify ( payload , null , 2 ) )
34+ . exec ( `curl -d@- -H "Content-Type: application/json" ${ webhookUrl } ` ) ;
35+ console . info ( 'Notified Slack about job failure.' ) ;
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments