1. Neil Muller
  2. bitbucket-post-to-irker

Overview

README

This is a simple python webapp which listens for POST hook calls from bitbucket and forwards them on to a local irkerd instance as an appropriately formatted json call.

SETUP

Run this as a simple webserver and point the github webhook or bitbucket's POST hook at the server.

The irker server, port, colour mode (mIRC or none) on can be configured in either the source, or the config file (loaded from the WEBHOOK_CONFIG env variable).

We support two variants on the url to post to:

Channels in the config file

In the default configuration, the channels are specified in source or the config file (CHANNELS), and just the project name is appended to the url.

For bitbucket, point the hook at:

http://server:port/bitbucket/project

For github, point the hook at:

http://server:port/github/project

where project is the project name that irker will use to announce commits.

Channels in the url

If SPECIFY_CHANNEL_IN_URL is True, the channel to announce commits on must be part of the URL, as well as the project name.

For bitbucket, point the hook at:

http://server:port/bitbucket/channel/project

For github, point the hook at:

http://server:port/github/channel/project

where project is the project name that irker will use to announce commits and channel is the channel to announce the commit to.

The channel must be one of the alllowed channels mentioned either in the source or in the config file, specified using ALLOWED_CHANNELS.

Multiple channels can be specified by combining them with ',', suitably quoted, since that is not legal in the channel. For example

http://server:port/github/channelA%2CchannelB/project

will post to both channelA and channelB. All channels must be in the allowed channel list, or nothing will be posted.

PULL_REQUESTS

To enable pull_request events on the web hook, you need to use the github api to configure a web service hook for this.

To enable the hook, post a suitable request to the github api:

curl -u "<user>"
-d '{ "name": "web",
"active": true, "events": ["pull_request"], "config": { "url": "http://server:port/github/project" }

}' https://api.github.com/repos/<user>/<project>/hooks

To list the enabled hooks, use
curl -u "<user>" https://api.github.com/repos/<user>/<project>/hooks

NB: The github doc examples use "content_type: json". While we do support this, it is not particularly well-tested code yet, so use with caution.

LOGGING OPTIONS

By default, this silently skips any exceptions from malformed posts and so forth.

To log errors more verbosely, set LOG_ERRORS in the config file

To log details of requests and messages sent to irker, for debugging and so forth, set LOG_INFO in the config file

Use LOG_FILE to set the output file, if desired