mirror of
https://gitlab.silvrtree.co.uk/martind2000/nci.git
synced 2025-02-14 07:59:15 +00:00
add mail notifier
This commit is contained in:
parent
6180f2cde4
commit
6d664213c5
1
app.js
1
app.js
@ -64,6 +64,7 @@ Steppy(
|
|||||||
// register plugins
|
// register plugins
|
||||||
require('./lib/reader/yaml').register(app);
|
require('./lib/reader/yaml').register(app);
|
||||||
require('./lib/notifier/console').register(app);
|
require('./lib/notifier/console').register(app);
|
||||||
|
require('./lib/notifier/mail').register(app);
|
||||||
|
|
||||||
reader.load(app.config.paths.data, 'config', this.slot());
|
reader.load(app.config.paths.data, 'config', this.slot());
|
||||||
},
|
},
|
||||||
|
@ -3,7 +3,13 @@ nodes:
|
|||||||
- type: local
|
- type: local
|
||||||
maxExecutorsCount: 2
|
maxExecutorsCount: 2
|
||||||
|
|
||||||
notify: {}
|
notify:
|
||||||
|
mail:
|
||||||
|
host: smtp.gmail.com
|
||||||
|
port: 587
|
||||||
|
auth:
|
||||||
|
user: bot.nci@gmail.com
|
||||||
|
pass: pass
|
||||||
|
|
||||||
httpApi:
|
httpApi:
|
||||||
host: 127.0.0.1
|
host: 127.0.0.1
|
||||||
|
@ -9,13 +9,14 @@ catchRev:
|
|||||||
|
|
||||||
notify:
|
notify:
|
||||||
on:
|
on:
|
||||||
# - done
|
- done
|
||||||
# - error
|
# - error
|
||||||
- change
|
- change
|
||||||
to:
|
to:
|
||||||
console:
|
console:
|
||||||
# email:
|
# mail:
|
||||||
# - oleg.korobenko@gmail.com
|
# - oleg.korobenko@gmail.com
|
||||||
|
# - oleg.poligon@gmail.com
|
||||||
# jabber:
|
# jabber:
|
||||||
# - oleg.korobenko@gmail.com
|
# - oleg.korobenko@gmail.com
|
||||||
|
|
||||||
|
52
lib/notifier/mail.js
Normal file
52
lib/notifier/mail.js
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
var BaseNotifier = require('./base').Notifier,
|
||||||
|
inherits = require('util').inherits,
|
||||||
|
Steppy = require('twostep').Steppy,
|
||||||
|
_ = require('underscore'),
|
||||||
|
nodemailer = require('nodemailer');
|
||||||
|
|
||||||
|
function Notifier() {
|
||||||
|
}
|
||||||
|
|
||||||
|
inherits(Notifier, BaseNotifier);
|
||||||
|
|
||||||
|
exports.register = function(app) {
|
||||||
|
app.lib.notifier.register('mail', Notifier);
|
||||||
|
};
|
||||||
|
|
||||||
|
Notifier.prototype.init = function(params, callback) {
|
||||||
|
this.transport = nodemailer.createTransport(params);
|
||||||
|
callback();
|
||||||
|
};
|
||||||
|
|
||||||
|
Notifier.prototype._subjectTemplate = _(
|
||||||
|
'<%= build.project.name %> build #<%= build.number %> ' +
|
||||||
|
'is <%= build.status %>'
|
||||||
|
).template();
|
||||||
|
|
||||||
|
Notifier.prototype._bodyTemplate = _(
|
||||||
|
'<%= build.project.name %> build #<%= build.number %> status: ' +
|
||||||
|
'<%= build.status %><br>' +
|
||||||
|
'Current revision is: ' +
|
||||||
|
'<%= build.scm.rev.author %>: <%= build.scm.rev.comment %>'
|
||||||
|
).template();
|
||||||
|
|
||||||
|
Notifier.prototype.send = function(params, callback) {
|
||||||
|
var self = this,
|
||||||
|
build = params.build;
|
||||||
|
|
||||||
|
Steppy(
|
||||||
|
function() {
|
||||||
|
var subject = self._subjectTemplate(params),
|
||||||
|
body = self._bodyTemplate(params);
|
||||||
|
|
||||||
|
self.transport.sendMail({
|
||||||
|
subject: subject,
|
||||||
|
html: body,
|
||||||
|
to: params.build.project.notify.to.mail.join(',')
|
||||||
|
}, this.slot());
|
||||||
|
},
|
||||||
|
callback
|
||||||
|
);
|
||||||
|
};
|
@ -34,6 +34,7 @@
|
|||||||
"js-yaml": "3.3.1",
|
"js-yaml": "3.3.1",
|
||||||
"nlevel": "1.0.2",
|
"nlevel": "1.0.2",
|
||||||
"node-static": "0.7.6",
|
"node-static": "0.7.6",
|
||||||
|
"nodemailer": "1.4.0",
|
||||||
"socket.io": "1.3.5",
|
"socket.io": "1.3.5",
|
||||||
"twostep": "0.4.1",
|
"twostep": "0.4.1",
|
||||||
"underscore": "1.8.2"
|
"underscore": "1.8.2"
|
||||||
|
Loading…
Reference in New Issue
Block a user