@eui/tools 6.4.1 → 6.4.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.version.properties +1 -1
- package/CHANGELOG.md +19 -0
- package/package.json +1 -2
- package/sandbox.js +16 -2
- package/scripts/utils/notification/common.js +23 -16
- package/scripts/utils/notification/mail-utils.js +1 -1
- package/scripts/utils/notification/message-stack.js +15 -28
- package/scripts/utils/notification/package.js +0 -2
- package/scripts/utils/notification/teams-utils.js +59 -17
- package/scripts/utils/tools.js +18 -2
- package/scripts/utils/notification/mailstack.js +0 -127
package/.version.properties
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
6.4.
|
|
1
|
+
6.4.3
|
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,22 @@
|
|
|
1
|
+
## 6.4.3 (2023-02-23)
|
|
2
|
+
|
|
3
|
+
##### Chores
|
|
4
|
+
|
|
5
|
+
* **other:**
|
|
6
|
+
* limit the number of commit output for MS Teams message - EUI-7146 [EUI-7146](https://webgate.ec.europa.eu/CITnet/jira/browse/EUI-7146) ([616070b3](https://webgate.ec.europa.eu/CITnet/stash/scm/csdr/eui-tools.git/commits/616070b3daaaae67fc5753c490290c14f9790738))
|
|
7
|
+
* adapted teams notification message for exception and commits outpuy - EUI-7146 [EUI-7146](https://webgate.ec.europa.eu/CITnet/jira/browse/EUI-7146) ([58f0f958](https://webgate.ec.europa.eu/CITnet/stash/scm/csdr/eui-tools.git/commits/58f0f9587af636311c43d9a979ea3d4acb5c5511))
|
|
8
|
+
|
|
9
|
+
* * *
|
|
10
|
+
* * *
|
|
11
|
+
## 6.4.2 (2023-02-22)
|
|
12
|
+
|
|
13
|
+
##### Chores
|
|
14
|
+
|
|
15
|
+
* **other:**
|
|
16
|
+
* adapted MS Teams notifications to fetch teams hook from CSDR_ARGS process variable - EUI-7146 [EUI-7146](https://webgate.ec.europa.eu/CITnet/jira/browse/EUI-7146) ([836a9c6a](https://webgate.ec.europa.eu/CITnet/stash/scm/csdr/eui-tools.git/commits/836a9c6a2ca634c6a09be95a1cc3062ff311ec78))
|
|
17
|
+
|
|
18
|
+
* * *
|
|
19
|
+
* * *
|
|
1
20
|
## 6.4.1 (2023-02-22)
|
|
2
21
|
|
|
3
22
|
##### Bug Fixes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eui/tools",
|
|
3
|
-
"version": "6.4.
|
|
3
|
+
"version": "6.4.3",
|
|
4
4
|
"tag": "latest",
|
|
5
5
|
"license": "EUPL-1.1",
|
|
6
6
|
"description": "eUI common tools and scripts",
|
|
@@ -42,7 +42,6 @@
|
|
|
42
42
|
"chai": "4.3.7",
|
|
43
43
|
"nyc": "15.1.0",
|
|
44
44
|
"node-fetch": "2.6.9",
|
|
45
|
-
"sendmail": "1.6.1",
|
|
46
45
|
"svg-sprite": "2.0.2",
|
|
47
46
|
"imagemin": "7.0.1",
|
|
48
47
|
"imagemin-svgo": "9.0.0",
|
package/sandbox.js
CHANGED
|
@@ -1181,8 +1181,22 @@ const versionUtils = require('./scripts/csdr/version/version-utils');
|
|
|
1181
1181
|
// })
|
|
1182
1182
|
|
|
1183
1183
|
|
|
1184
|
+
// const teamsUtils = require('./scripts/utils/notification/teams-utils');
|
|
1185
|
+
|
|
1186
|
+
// Promise.resolve()
|
|
1187
|
+
// .then(() => {
|
|
1188
|
+
// console.log(teamsUtils.getChannelHook('pipeline-ui-edui'));
|
|
1189
|
+
// })
|
|
1190
|
+
|
|
1184
1191
|
Promise.resolve()
|
|
1185
1192
|
.then(() => {
|
|
1186
|
-
|
|
1187
|
-
|
|
1193
|
+
|
|
1194
|
+
var startTime = moment('03-01-2021 01:01:01', 'DD-MM-YYYY hh:mm:ss');
|
|
1195
|
+
var endTime = moment('03-01-2021 01:04:53', 'DD-MM-YYYY hh:mm:ss');
|
|
1196
|
+
|
|
1197
|
+
var secondsDiff = endTime.diff(startTime, 's');
|
|
1198
|
+
|
|
1199
|
+
const getMinSec = (s) => { return(s-(s%=60))/60+'m'+(9<s?':':':0')+s+'s'; }
|
|
1200
|
+
const minSec = getMinSec(secondsDiff);
|
|
1201
|
+
console.log(minSec);
|
|
1188
1202
|
})
|
|
@@ -12,6 +12,7 @@ module.exports.getMessage = (options) => {
|
|
|
12
12
|
mainText: null,
|
|
13
13
|
detailTitle: null,
|
|
14
14
|
detailText: null,
|
|
15
|
+
detailTextArray: [],
|
|
15
16
|
text: options.text || null,
|
|
16
17
|
status: null,
|
|
17
18
|
statusColor: null
|
|
@@ -41,55 +42,57 @@ module.exports.getMessage = (options) => {
|
|
|
41
42
|
switch (options.exception) {
|
|
42
43
|
case 'NO_VALID_COMMIT_FOUND':
|
|
43
44
|
message.detailTitle = 'NO VALID COMMIT FOUND!';
|
|
44
|
-
message.
|
|
45
|
+
message.detailTextArray.push('No valid commit found since last release tag');
|
|
45
46
|
break;
|
|
46
47
|
|
|
47
48
|
case 'NO_ISSUE_FOUND':
|
|
48
49
|
message.detailTitle = 'NO ISSUE FOUND!';
|
|
49
|
-
message.
|
|
50
|
+
message.detailTextArray.push('No issue found on commits since last release tag');
|
|
51
|
+
message.detailTextArray.push('Commit details:');
|
|
50
52
|
if (options.metadata.commits && options.metadata.commits.length !== 0) {
|
|
51
|
-
|
|
53
|
+
const commits = options.metadata.commits.map((commit) => {
|
|
52
54
|
return metadataUtils.commit.formatCommit(commit);
|
|
53
|
-
})
|
|
55
|
+
});
|
|
56
|
+
message.detailTextArray = [...message.detailTextArray, ...commits];
|
|
54
57
|
}
|
|
55
58
|
break;
|
|
56
59
|
|
|
57
60
|
case 'GLOBAL_PIPELINE_DISABLED':
|
|
58
61
|
message.detailTitle = 'PIPELINE GLOBALLY DISABLED!';
|
|
59
|
-
message.
|
|
62
|
+
message.detailTextArray.push('Due to maintenance, all pipeline jobs have been temporary disabled - retry later');
|
|
60
63
|
break;
|
|
61
64
|
|
|
62
65
|
case 'PACKAGE_LOCKED':
|
|
63
66
|
message.detailTitle = 'CONCURRENT BUILD DETECTED FOR PACKAGE - ABORTING!';
|
|
64
|
-
message.
|
|
67
|
+
message.detailTextArray.push('Another build has been detected for the current package being build\n Retry again this build after 15m, lock will be auto-cleared');
|
|
65
68
|
break;
|
|
66
69
|
|
|
67
70
|
case 'MULTIPLE_LOCAL_EUI_VERSIONS_FOUND':
|
|
68
71
|
message.detailTitle = 'MULTIPLE eUI VERSIONS FOUND IN LOCAL PROJECT - ABORTING!';
|
|
69
|
-
message.
|
|
72
|
+
message.detailTextArray.push('Uncompatible version of eUI found installed in the local CSDR project, please adjust and keep same compatible versions of eUI packages and projects');
|
|
70
73
|
break;
|
|
71
74
|
|
|
72
75
|
case 'BRANCH_NOT_PROVIDED':
|
|
73
76
|
message.detailTitle = 'RELEASE BRANCH missing - ABORTING!';
|
|
74
|
-
message.
|
|
77
|
+
message.detailTextArray.push('Package release needs to have a branch to build from as parameter from Bamboo');
|
|
75
78
|
break;
|
|
76
79
|
|
|
77
80
|
case 'REMOTE_ENVTARGET_NOT_MASTER_BRANCH':
|
|
78
81
|
message.detailTitle = 'REMOTE envTarget type branchis different from master - ABORTING!';
|
|
79
|
-
message.
|
|
82
|
+
message.detailTextArray.push('For envTarget remote delivery or "à la carte", only the master branch is allowed for build, contact support if any question');
|
|
80
83
|
break;
|
|
81
84
|
|
|
82
85
|
case 'AUDIT_DEPENDENCIES_GATES_FAILED':
|
|
83
|
-
message.detailTitle = '
|
|
84
|
-
message.
|
|
86
|
+
message.detailTitle = 'AUDIT DEPENDENCIES GATES FAILED';
|
|
87
|
+
message.detailTextArray.push('Audit dependencies gates for current eUI version contains blocking vulnerabilities - ABORTING!');
|
|
85
88
|
break;
|
|
86
89
|
|
|
87
90
|
default:
|
|
88
91
|
message.detailTitle = 'GENERAL ERROR!';
|
|
89
|
-
message.
|
|
92
|
+
message.detailTextArray.push(options.exception);
|
|
90
93
|
};
|
|
91
94
|
|
|
92
|
-
|
|
95
|
+
message.detailText = message.detailTextArray.join('\n');
|
|
93
96
|
|
|
94
97
|
} else {
|
|
95
98
|
|
|
@@ -106,12 +109,16 @@ module.exports.getMessage = (options) => {
|
|
|
106
109
|
|
|
107
110
|
if (options.metadata && options.metadata.commits && options.metadata.commits.length !== 0) {
|
|
108
111
|
message.detailTitle = 'Commit history since last release tag';
|
|
109
|
-
|
|
112
|
+
const formattedCommits = options.metadata.commits.map((commit) => {
|
|
110
113
|
return metadataUtils.commit.formatCommit(commit);
|
|
111
|
-
})
|
|
114
|
+
});
|
|
115
|
+
message.detailText = formattedCommits.join('\n ');
|
|
116
|
+
message.detailTextArray = formattedCommits;
|
|
112
117
|
|
|
113
118
|
if (options.metadata.issues && options.metadata.issues.length !== 0) {
|
|
114
|
-
|
|
119
|
+
const extractedIssuesText = 'Extracted issues : ' + options.metadata.issues;
|
|
120
|
+
message.detailText += '\n' + extractedIssuesText;
|
|
121
|
+
message.detailTextArray.push(extractedIssuesText);
|
|
115
122
|
}
|
|
116
123
|
}
|
|
117
124
|
}
|
|
@@ -8,7 +8,7 @@ let { dryRun, debug} = tools.getArgs();
|
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
const sendCore = (subject, body, recipient) => {
|
|
11
|
-
const sendmail = require('sendmail')();
|
|
11
|
+
const sendmail = require('sendmail')(); // if used in the future and needed this deps is required : "sendmail": "1.6.1"
|
|
12
12
|
|
|
13
13
|
tools.logInfo(`Sending mail to : ${recipient}`);
|
|
14
14
|
tools.logInfo('Message subject / body :');
|
|
@@ -10,9 +10,6 @@ const tools = require('../tools');
|
|
|
10
10
|
const innerConfig = require('./config');
|
|
11
11
|
const innerTeamsUtils = require('./teams-utils');
|
|
12
12
|
|
|
13
|
-
// ARGS
|
|
14
|
-
const { dryRun, debug, notificationActive } = tools.getArgs();
|
|
15
|
-
|
|
16
13
|
|
|
17
14
|
// ---------------------------------------------------------------------------------------
|
|
18
15
|
// MESSAGE BUFFER
|
|
@@ -25,6 +22,7 @@ const messageContent = {
|
|
|
25
22
|
startTimestamp: null,
|
|
26
23
|
endTimestamp: null,
|
|
27
24
|
duration: null,
|
|
25
|
+
durationSeconds: null,
|
|
28
26
|
durationMinSec: null
|
|
29
27
|
};
|
|
30
28
|
|
|
@@ -36,7 +34,9 @@ module.exports.endStack = () => {
|
|
|
36
34
|
messageContent.endTimestamp = moment();
|
|
37
35
|
messageContent.duration = messageContent.endTimestamp - messageContent.startTimestamp;
|
|
38
36
|
const start = messageContent.startTimestamp, end = messageContent.endTimestamp;
|
|
39
|
-
messageContent.
|
|
37
|
+
messageContent.durationSeconds = end.diff(start, 's');
|
|
38
|
+
const getMinSec = (s) => { return(s-(s%=60))/60+'m'+(9<s?':':':0')+s+'s'; }
|
|
39
|
+
messageContent.durationMinSec = getMinSec(messageContent.durationSeconds);
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
module.exports.pushMessage = (message) => {
|
|
@@ -44,36 +44,23 @@ module.exports.pushMessage = (message) => {
|
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
|
|
47
|
-
|
|
48
47
|
const sendMessage = (config) => {
|
|
49
|
-
|
|
50
48
|
if (config.CLIENT === 'SLACK') {
|
|
51
49
|
return Promise.resolve();
|
|
52
50
|
}
|
|
53
51
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
console.log(messageContent);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
return Promise.resolve();
|
|
52
|
+
return Promise.resolve()
|
|
53
|
+
.then(() => {
|
|
54
|
+
if (config.CLIENT === 'MSTEAMS') {
|
|
55
|
+
return innerTeamsUtils.sendMessage(config, messageContent);
|
|
62
56
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
// TODO IF MAIL NOTIF IS NEEDED...
|
|
71
|
-
}
|
|
72
|
-
})
|
|
73
|
-
.catch((e) => {
|
|
74
|
-
throw e;
|
|
75
|
-
})
|
|
76
|
-
}
|
|
57
|
+
} else if (config.CLIENT === 'MAIL') {
|
|
58
|
+
// TODO IF MAIL NOTIF IS NEEDED...
|
|
59
|
+
}
|
|
60
|
+
})
|
|
61
|
+
.catch((e) => {
|
|
62
|
+
throw e;
|
|
63
|
+
})
|
|
77
64
|
}
|
|
78
65
|
|
|
79
66
|
|
|
@@ -56,8 +56,6 @@ module.exports.sendPackageDiffReportMessage = (pkg, diffMetadata) => {
|
|
|
56
56
|
if (config.CLIENT === 'SLACK') {
|
|
57
57
|
return Promise.resolve()
|
|
58
58
|
.then(() => {
|
|
59
|
-
const config = innerConfig.getPackageConfig(pkg);
|
|
60
|
-
|
|
61
59
|
return slackUtils.sendPackageDiffReportMessage(
|
|
62
60
|
diffMetadata,
|
|
63
61
|
config.SLACK_HOOK,
|
|
@@ -9,10 +9,22 @@ const configUtils = require('../../csdr/config/config-utils');
|
|
|
9
9
|
const { dryRun, debug} = tools.getArgs();
|
|
10
10
|
|
|
11
11
|
|
|
12
|
-
const getChannelHook = (channelName) => {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
const getChannelHook = module.exports.getChannelHook = (channelName) => {
|
|
13
|
+
const { msteamsHooksArray } = tools.getArgs();
|
|
14
|
+
|
|
15
|
+
const msteamsHook = msteamsHooksArray.filter((h) => {
|
|
16
|
+
return Object.keys(h)[0] === channelName;
|
|
17
|
+
})[0];
|
|
18
|
+
|
|
19
|
+
if (!msteamsHook) {
|
|
20
|
+
tools.logInfo(`Channel hook can't be found for ${channelName} - check _CSDR_ARGS entries in gitlab pipeline configuration`);
|
|
21
|
+
|
|
22
|
+
// TODO set default channels in global config by type
|
|
23
|
+
// const globalConfig = configUtils.global.getConfigOptions();
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
return msteamsHook[channelName];
|
|
16
28
|
}
|
|
17
29
|
|
|
18
30
|
|
|
@@ -42,11 +54,19 @@ const createPayload = (messageContent) => {
|
|
|
42
54
|
const version = finalMessage.version;
|
|
43
55
|
|
|
44
56
|
// set commit history
|
|
45
|
-
|
|
57
|
+
let commitHistory = [], exceptionDetails = [];
|
|
58
|
+
if (status === statuses.success) {
|
|
59
|
+
commitHistory = finalMessage.detailTextArray;
|
|
60
|
+
} else {
|
|
61
|
+
exceptionDetails = finalMessage.detailTextArray;
|
|
62
|
+
}
|
|
46
63
|
|
|
47
64
|
// set summary
|
|
48
65
|
const itemName = messageContent.buffer[0].scope;
|
|
49
|
-
|
|
66
|
+
let summary = `${status.emoji} :: ${status.text} - ${itemName}`;
|
|
67
|
+
if (version) {
|
|
68
|
+
summary += ` - ${version}`;
|
|
69
|
+
}
|
|
50
70
|
|
|
51
71
|
// set release sections
|
|
52
72
|
const publications = messageContent.buffer.filter(m => m.text !== null && m.text.indexOf(':rocket:') > -1);
|
|
@@ -59,11 +79,29 @@ const createPayload = (messageContent) => {
|
|
|
59
79
|
}
|
|
60
80
|
});
|
|
61
81
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
82
|
+
if (commitHistory.length > 0) {
|
|
83
|
+
sections.push({
|
|
84
|
+
"startGroup": true,
|
|
85
|
+
"activityTitle": "Commit history since last release tag"
|
|
86
|
+
});
|
|
87
|
+
commitHistory.slice(0, 5).forEach((commit) => {
|
|
88
|
+
sections.push({
|
|
89
|
+
"activityText": commit
|
|
90
|
+
});
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
if (exceptionDetails.length > 0) {
|
|
95
|
+
sections.push({
|
|
96
|
+
"startGroup": true,
|
|
97
|
+
"activityTitle": finalMessage.detailTitle
|
|
98
|
+
});
|
|
99
|
+
exceptionDetails.forEach((exd) => {
|
|
100
|
+
sections.push({
|
|
101
|
+
"activityText": exd
|
|
102
|
+
});
|
|
103
|
+
});
|
|
104
|
+
}
|
|
67
105
|
|
|
68
106
|
sections.push({
|
|
69
107
|
"startGroup": true,
|
|
@@ -91,15 +129,19 @@ module.exports.sendMessage = (config, messageContent) => {
|
|
|
91
129
|
tools.logTitle('Sending MS teams message');
|
|
92
130
|
|
|
93
131
|
const channelHook = getChannelHook(config.MSTEAMS_CHANNEL);
|
|
132
|
+
|
|
133
|
+
if (!channelHook) {
|
|
134
|
+
return Promise.resolve();
|
|
135
|
+
}
|
|
136
|
+
|
|
94
137
|
const payload = createPayload(messageContent);
|
|
95
138
|
|
|
139
|
+
if (debug) {
|
|
140
|
+
console.log(messageContent);
|
|
141
|
+
console.log(JSON.parse(JSON.stringify(payload, null, 2)));
|
|
142
|
+
}
|
|
143
|
+
|
|
96
144
|
return Promise.resolve()
|
|
97
|
-
.then(() => {
|
|
98
|
-
if (debug) {
|
|
99
|
-
console.log(messageContent);
|
|
100
|
-
console.log(JSON.parse(JSON.stringify(payload, null, 2)));
|
|
101
|
-
}
|
|
102
|
-
})
|
|
103
145
|
.then(() => {
|
|
104
146
|
const host = configUtils.global.getConfigOptions().MSTEAMS_HOST;
|
|
105
147
|
|
package/scripts/utils/tools.js
CHANGED
|
@@ -68,8 +68,24 @@ function getArgs() {
|
|
|
68
68
|
|
|
69
69
|
if (processArgs) {
|
|
70
70
|
processArgs.split(',').forEach((item) => {
|
|
71
|
-
|
|
72
|
-
|
|
71
|
+
// check if it's defined as array - example format : someArray:test1=test1|test2=test2
|
|
72
|
+
if (item.indexOf('Array') > 0) {
|
|
73
|
+
const arrayItems = item.split(':')[1];
|
|
74
|
+
const subItems = arrayItems.split('|');
|
|
75
|
+
const array = [];
|
|
76
|
+
subItems.forEach((sub) => {
|
|
77
|
+
const subItemSplit = sub.split('=');
|
|
78
|
+
const newItem = {};
|
|
79
|
+
newItem[subItemSplit[0].trim()] = subItemSplit[1].trim();
|
|
80
|
+
array.push(newItem);
|
|
81
|
+
})
|
|
82
|
+
args[item.split(':')[0]] = array;
|
|
83
|
+
|
|
84
|
+
// otherwise normal key/value pairs - example format : test1:test1,test2:test2
|
|
85
|
+
} else {
|
|
86
|
+
const itemSplit = item.split(':');
|
|
87
|
+
args[itemSplit[0].trim()] = itemSplit[1].trim();
|
|
88
|
+
}
|
|
73
89
|
})
|
|
74
90
|
}
|
|
75
91
|
|
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
// GLOBAL
|
|
4
|
-
const moment = require('moment');
|
|
5
|
-
|
|
6
|
-
// LOCAL
|
|
7
|
-
const mailUtils = require('./mail-utils');
|
|
8
|
-
const tools = require('../tools');
|
|
9
|
-
|
|
10
|
-
// INNER
|
|
11
|
-
const innerConfig = require('./config');
|
|
12
|
-
|
|
13
|
-
// FETCH ARGS
|
|
14
|
-
let { dryRun, debug } = tools.getArgs();
|
|
15
|
-
|
|
16
|
-
// ---------------------------------------------------------------------------------------
|
|
17
|
-
// MAIL BUFFER
|
|
18
|
-
// - used for storing all message happening during a run
|
|
19
|
-
// - used for MS Teams mail notifications, to avoid multiple message send for a single run
|
|
20
|
-
// ---------------------------------------------------------------------------------------
|
|
21
|
-
|
|
22
|
-
const mailContent = {
|
|
23
|
-
buffer: [],
|
|
24
|
-
exception: null,
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
module.exports.startMailStack = () => {
|
|
28
|
-
mailContent.buffer.push(`CSDR RUN - START - ${moment(new Date()).format("DD/MM/YYYY HH:mm")}\n\n`);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
module.exports.endMailStack = () => {
|
|
32
|
-
mailContent.buffer.push(`CSDR RUN - END - ${moment(new Date()).format("DD/MM/YYYY HH:mm")}`);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
module.exports.bufferMessage = (message) => {
|
|
36
|
-
if (message.text) {
|
|
37
|
-
mailContent.buffer.push(message.text);
|
|
38
|
-
|
|
39
|
-
} else {
|
|
40
|
-
mailContent.buffer.push(message.mainTitle);
|
|
41
|
-
mailContent.buffer.push(message.mainText);
|
|
42
|
-
|
|
43
|
-
if (message.detailTitle) {
|
|
44
|
-
mailContent.buffer.push(message.detailTitle);
|
|
45
|
-
mailContent.buffer.push(message.detailText);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
if (message.scope) {
|
|
49
|
-
let subMessage = `>> <b>${message.scope}</b>`;
|
|
50
|
-
if (message.version) {
|
|
51
|
-
subMessage += `- <b>${message.version}</b>`;
|
|
52
|
-
}
|
|
53
|
-
mailContent.buffer.push(subMessage);
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
if (message.exception) {
|
|
58
|
-
mailContent.exception = message.exception;
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
const sendMailStack = (config, scope, target) => {
|
|
64
|
-
return Promise.resolve()
|
|
65
|
-
.then(() => {
|
|
66
|
-
let statusColor = 'green', status = 'SUCCESS';
|
|
67
|
-
|
|
68
|
-
if (mailContent.exception) {
|
|
69
|
-
statusColor = 'red';
|
|
70
|
-
status = 'ERROR';
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
// const subject = `RELEASE <b style="color: ${statusColor};">${status}</b> - <b style="color:blue;">${scope}</b> - branch: <b styles="color: blue;">${target}</b>`;
|
|
74
|
-
const subject = `Release of **${scope}** for ${target} ---- status : ${status}`;
|
|
75
|
-
let fullMessage = `<pre>${mailContent.buffer.join('\n')}</pre>`;
|
|
76
|
-
|
|
77
|
-
if (mailContent.exception) {
|
|
78
|
-
fullMessage += mailContent.exception;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
if (config.CLIENT === 'MAIL') {
|
|
82
|
-
return mailUtils.sendMessage(subject, fullMessage, config.MAIL_ADDRESS);
|
|
83
|
-
|
|
84
|
-
} else {
|
|
85
|
-
console.log(fullMessage);
|
|
86
|
-
}
|
|
87
|
-
})
|
|
88
|
-
|
|
89
|
-
.catch((e) => {
|
|
90
|
-
throw e;
|
|
91
|
-
})
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
module.exports.sendMailStackPackage = (pkg, branches) => {
|
|
98
|
-
|
|
99
|
-
// getting package notification config
|
|
100
|
-
const config = innerConfig.getPackageConfig(pkg);
|
|
101
|
-
|
|
102
|
-
return Promise.resolve()
|
|
103
|
-
.then(() => {
|
|
104
|
-
return sendMailStack(config, pkg.name, branches.branch);
|
|
105
|
-
})
|
|
106
|
-
|
|
107
|
-
.catch((e) => {
|
|
108
|
-
throw e;
|
|
109
|
-
})
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
module.exports.sendMailStackProject = (project, envTarget) => {
|
|
114
|
-
|
|
115
|
-
// getting package notification config
|
|
116
|
-
const config = innerConfig.getProjectConfig(project);
|
|
117
|
-
|
|
118
|
-
return Promise.resolve()
|
|
119
|
-
.then(() => {
|
|
120
|
-
return sendMailStack(config, project.name, envTarget);
|
|
121
|
-
})
|
|
122
|
-
|
|
123
|
-
.catch((e) => {
|
|
124
|
-
throw e;
|
|
125
|
-
})
|
|
126
|
-
}
|
|
127
|
-
|