Permalink
Browse files

Merge

  • Loading branch information...
2 parents 2cd7a95 + fbb19bc commit 43fd5f23fe4d1843bca8b0509ae64f648c5843df @tombell tombell committed Jan 10, 2013
Showing with 27 additions and 1 deletion.
  1. +27 −1 src/scripts/travis.coffee
View
@@ -1,19 +1,29 @@
# Description:
# Find the build status of an open-source project on Travis
+# Can also notify about builds, just enable the webhook notification on travis http://about.travis-ci.org/docs/user/build-configuration/ -> 'Webhook notification'
#
# Dependencies:
-# None
+# "gitio": "1.0.1"
#
# Configuration:
# None
#
# Commands:
# hubot travis me <user>/<repo> - Returns the build status of https://github.com/<user>/<repo>
#
+# URLS:
+# POST /hubot/travis?room=<room>[&type=<type]
+#
# Author:
# sferik
+# nesQuick
+
+url = require('url')
+querystring = require('querystring')
+gitio = require('gitio')
module.exports = (robot) ->
+
robot.respond /travis me (.*)/i, (msg) ->
project = escape(msg.match[1])
msg.http("https://api.travis-ci.org/repos/#{project}")
@@ -25,3 +35,19 @@ module.exports = (robot) ->
msg.send "Build status for #{project}: Failing"
else
msg.send "Build status for #{project}: Unknown"
+
+ robot.router.post "/hubot/travis", (req, res) ->
+ query = querystring.parse url.parse(req.url).query
+ res.end JSON.stringify {
+ received: true #some client have problems with and empty response
+ }
+
+ user = {}
+ user.room = query.room if query.room
+ user.type = query.type if query.type
+
+ payload = JSON.parse req.body.payload
+
+ if payload.status isnt 0
+ gitio payload.compare_url, (err, data) ->
+ robot.send user, "#{payload.author_name} broke the build (#{payload.build_url}) of #{payload.repository.name} with commit (#{if err then payload.compare_url else data})!"

0 comments on commit 43fd5f2

Please sign in to comment.