-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbitbucket.coffee
More file actions
executable file
·29 lines (24 loc) · 855 Bytes
/
bitbucket.coffee
File metadata and controls
executable file
·29 lines (24 loc) · 855 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# 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:
# http://confluence.atlassian.com/display/BITBUCKET/Setting+Up+the+bitbucket+POST+Service
#
# 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()