@@ -4,14 +4,63 @@ const { werft, exec, gitTag } = require('./util/shell.js');
4
4
const { sleep } = require ( './util/util.js' ) ;
5
5
const { wipeAndRecreateNamespace, setKubectlContextNamespace, deleteNonNamespaceObjects } = require ( './util/kubectl.js' ) ;
6
6
const { issueAndInstallCertficate } = require ( './util/certs.js' ) ;
7
+ const https = require ( 'https' ) ;
7
8
8
9
const GCLOUD_SERVICE_ACCOUNT_PATH = "/mnt/secrets/gcp-sa/service-account.json" ;
9
10
10
11
const context = JSON . parse ( fs . readFileSync ( 'context.json' ) ) ;
11
12
12
13
const version = parseVersion ( context ) ;
13
14
build ( context , version )
14
- . catch ( ( err ) => process . exit ( 1 ) ) ;
15
+ . catch ( ( err ) => {
16
+ if ( context . Repository . ref === "refs/heads/master" ) {
17
+ const repo = context . Repository . host + "/" + context . Repository . owner + "/" + context . Repository . repo ;
18
+ const data = JSON . stringify ( {
19
+ "blocks" : [
20
+ {
21
+ "type" : "section" ,
22
+ "text" : {
23
+ "type" : "mrkdwn" ,
24
+ "text" : ":X: *build failure*\n_Repo:_ `" + repo + "`\n_Build:_ `" + context . Name + "`"
25
+ } ,
26
+ "accessory" : {
27
+ "type" : "button" ,
28
+ "text" : {
29
+ "type" : "plain_text" ,
30
+ "text" : "Go to Werft" ,
31
+ "emoji" : true
32
+ } ,
33
+ "value" : "click_me_123" ,
34
+ "url" : "https://werft.gitpod-dev.com/job/" + context . Name ,
35
+ "action_id" : "button-action"
36
+ }
37
+ } ,
38
+ {
39
+ "type" : "section" ,
40
+ "text" : {
41
+ "type" : "mrkdwn" ,
42
+ "text" : "```\n" + err + "\n```"
43
+ }
44
+ }
45
+ ]
46
+ } ) ;
47
+ const req = https . request ( {
48
+ hostname : "hooks.slack.com" ,
49
+ port : 443 ,
50
+ path : process . env . SLACK_NOTIFICATION_PATH . trim ( ) ,
51
+ method : "POST" ,
52
+ headers : {
53
+ 'Content-Type' : 'application/json' ,
54
+ 'Content-Length' : data . length ,
55
+ }
56
+ } , ( ) => process . exit ( 1 ) ) ;
57
+ req . on ( 'error' , ( ) => process . exit ( 1 ) ) ;
58
+ req . write ( data ) ;
59
+ req . end ( ) ;
60
+ } else {
61
+ process . exit ( 1 ) ;
62
+ }
63
+ } ) ;
15
64
16
65
function parseVersion ( context ) {
17
66
let buildConfig = context . Annotations || { } ;
0 commit comments