Browse files

Added SendGrid support

  • Loading branch information...
1 parent 4d71ee0 commit c7578cd418c2b43549350143c4535a8fdd07b79e @theycallmeswift committed Oct 21, 2012
Showing with 17 additions and 2 deletions.
  1. +2 −1 package.json
  2. +15 −1 server.js
View
3 package.json
@@ -19,6 +19,7 @@
"dependencies": {
"express": "~3.0.0rc5",
"johnny-five": "~0.5.14",
- "async": "~0.1.22"
+ "async": "~0.1.22",
+ "sendgrid": "~0.2.5"
}
}
View
16 server.js
@@ -2,6 +2,8 @@ var util = require('util')
, test_bot = require('./test_bot')
, Testuino = require('./testuino')
, testuino = new Testuino
+ , SendGrid = require('sendgrid').SendGrid
+ , sendgrid = new SendGrid(process.env.SENDGRID_USER, process.env.SENDGRID_PASS)
, express = require('express')
, app = express()
, port = process.env.PORT || 3000
@@ -33,7 +35,19 @@ app.post('/github', function(req, res) {
util.log("Testing commit by " + lastCommit.author.name + " for " + url);
test_bot.test(name, url, lastCommit.id, function(err, pass) {
- testuino.finish(!err && pass);
+ var passed = (!err && pass)
+ , passText = (passed) ? "PASS" : "FAIL"
+ , text = "You last build for " + name + " just made it through Testuino! It resulted in a: " + passText + ". \n\r\n\r You can view the commit on github here: \n\r\n\r" + payload.repository.url + "\n\r\n\r Thanks,\n\rThe Testuino Notifier";
+
+ testuino.finish(passed);
+ sendgrid.send({
+ to: lastCommit.author.email,
+ from: 'build.notifier@testuino.com',
+ subject: 'Build status for ' + payload.repository.owner.name + '/' + name,
+ text: text
+ }, function(success, message) {
+ if(!success) util.log(message);
+ });
});
res.send("OK");

0 comments on commit c7578cd

Please sign in to comment.