Permalink
e2ec635 May 27, 2015
@tombell @mtrl @jrusbatch
30 lines (24 sloc) 839 Bytes
# Description:
# Announce changes to BitBucket repositories using BitBucket's POST service
# to a room sepecified by the URL.
#
# Dependencies:
# None
#
# Configuration:
# For instructions on how to set up BitBucket's POST service for your
# repositories, visit:
# https://confluence.atlassian.com/display/BITBUCKET/POST+hook+management
#
# Author:
# JRusbatch
module.exports = (robot) ->
robot.router.post '/hubot/bitbucket/:room', (req, res) ->
room = req.params.room
data = JSON.parse req.body.payload
commits = data.commits
msg = "#{data.user} pushed #{commits.length} commits to #{data.repository.name}:\n\n"
msg += "[#{commit.branch}] #{commit.message}\n" for commit in commits
robot.messageRoom room, msg
res.writeHead 204, { 'Content-Length': 0 }
res.end()