mirror of
https://gitlab.silvrtree.co.uk/martind2000/nci.git
synced 2025-02-10 17:49:17 +00:00
move mail notification plugin to separate repository
This commit is contained in:
parent
d17e1d1ed2
commit
a6c88f2aca
6
app.js
6
app.js
@ -76,6 +76,7 @@ Steppy(
|
||||
var preload = require(app.config.paths.preload);
|
||||
// register rc plugins
|
||||
_(preload.plugins).each(function(plugin) {
|
||||
logger.log('Preload plugin "%s"', plugin);
|
||||
require(plugin).register(app);
|
||||
});
|
||||
}
|
||||
@ -108,7 +109,10 @@ Steppy(
|
||||
|
||||
// register other plugins
|
||||
require('./lib/notifier/console').register(app);
|
||||
require('./lib/notifier/mail').register(app);
|
||||
_(app.config.plugins).each(function(plugin) {
|
||||
logger.log('Load plugin "%s"', plugin);
|
||||
require(plugin).register(app);
|
||||
});
|
||||
require('./httpApi').register(app);
|
||||
|
||||
notifier.init(app.config.notify, this.slot());
|
||||
|
@ -1,4 +1,7 @@
|
||||
|
||||
plugins:
|
||||
# - nci-mail-notification
|
||||
|
||||
nodes:
|
||||
- type: local
|
||||
maxExecutorsCount: 2
|
||||
|
@ -8,7 +8,7 @@ var Steppy = require('twostep').Steppy,
|
||||
* Pure rest api on pure nodejs follows below
|
||||
*/
|
||||
exports.register = function(app) {
|
||||
var config = app.config.httpApi,
|
||||
var config = _(app.config.httpApi).defaults({host: '127.0.0.1', port: 3030}),
|
||||
projects = app.projects,
|
||||
distributor = app.distributor,
|
||||
logger = app.lib.logger('http api');
|
||||
@ -55,5 +55,6 @@ exports.register = function(app) {
|
||||
);
|
||||
});
|
||||
|
||||
logger.log('Start listenning on %s:%s', config.host, config.port);
|
||||
server.listen(config.port, config.host);
|
||||
};
|
||||
|
@ -3,7 +3,11 @@
|
||||
var Steppy = require('twostep').Steppy,
|
||||
_ = require('underscore'),
|
||||
db = require('../../db'),
|
||||
logger = require('../logger')('notifier');
|
||||
logger = require('../logger')('notifier'),
|
||||
BaseNotifier = require('./base').Notifier;
|
||||
|
||||
|
||||
exports.BaseNotifier = BaseNotifier;
|
||||
|
||||
var constructors = {},
|
||||
instances = {};
|
||||
|
@ -1,52 +0,0 @@
|
||||
'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
|
||||
);
|
||||
};
|
@ -40,7 +40,6 @@
|
||||
"jade": "1.9.2",
|
||||
"nlevel": "1.0.2",
|
||||
"node-static": "0.7.6",
|
||||
"nodemailer": "1.4.0",
|
||||
"socket.io": "1.3.5",
|
||||
"twostep": "0.4.1",
|
||||
"underscore": "1.8.3"
|
||||
|
Loading…
Reference in New Issue
Block a user