Skip to main content

Django app that integrats BitBucket POST hook calls and your Trello boards.

Project description



Django app to integrate BitBucket POST hooks and Trello boards




Peter Sanchez <> - Netlandish Inc. (


  • Python 2.7+

  • Django 1.7+

  • trello 0.9.1+

  • requests 2.2.1+



pip install django-trello-broker

Basic Manual Install:

$ python build
$ sudo python install

Alternative Install (Manually):

Place trello_broker directory in your Python path. Either in your Python installs site-packages directory or set your $PYTHONPATH environment variable to include a directory where the trello_broker directory lives.


  1. Add ‘trello_broker’ to your INSTALLED_APPS

  2. Add ‘trello_broker.urls’ somewhere in your url structure. Example:

    urlpatterns = patterns('',
        url(r'^admin/', include(,
        url(r'^broker', include('trello_broker.urls')),
        ... (all your other urls here) ...
  3. Add at least 1 Trello Token to the database. Example:

    $ ./ add_trello_token
    Enter your Trello applications name.
    App Name: Netlandish Bot
    Enter your Trello user API Key. You can get it from:
    API Key: <Our Super Secret Key Here>
    Go to the following URL to get your API Token:<Our Super Secret Key Here>&name=Netlandish+Bot&expiration=never&response_type=token&scope=read,write
    API Token: <Our Super Secret Token Here>
    Saved token (ID: 1) to the database.
  4. Now you can automatically populate all Trello boards the new token has access to. Example:

    $ ./ populate_trello_boards
    Processing token Netlandish Bot
    Processing board BracketWire Development
    Processing board Bracketwire Planning
    Processing board CHAP Development
    Processing board CHAP Planning
    Processing board CartFreak Development
    Processing board CartFreak Planning
  5. Go to (or your admin URL) and add BitBucket Repositories. After saving you’ll be able to add a new “Rule”. Once you save that rule, you’ll be able to add another. Currently there are only 2 rules allowed. “Referenced” and “Fixes / Closes”.


When a card has been referenced in a commit message, this rule will be triggered.


Simply using “#<card-short-id>” works. For instance, “Starting working on new feature for #213”

Fixes / Closes

When a card has been referenced in a commit message but also uses a “fix” or “close” prefix


One of the following words following by the card short ID. Words are “fix(ed|es)” or “close(d|s)”. This is case insensitive. For instance, “Finished work for new feature. Closes #213”

#. Add the post hook to your BitBucket repository settings. See BitBucket POST Hook Management

Note Be sure to include the access_key if you stored one in your BitBucket Repo in the Django Admin. For instance, if you used “foobar” as your access key in Django admin, in the BitBucket settings you need to pass in the access key like so:


There are a few settings that the application supports.

  1. TRELLO_BROKER_USE_CELERY - Defaults to False. If True, the broker processor will use the celery task “celery_process_commits” which is simply a wrapper for the normal “process_commits” function to run via your celery setup.

  2. TRELLO_BROKER_RESTRICT_IPS - Defaults to False. If True, the broker will check that the client sending the request comes from the specified BitBucket broker servers. See: BitBucket IP List Here

  3. TRELLO_BROKER_BITBUCKET_IPS - A list of client IP’s that are allowed to POST to the broker. Default’s to

    ['', '']

    This setting depends on TRELLO_BROKER_RESTRICT_IPS being set to True


There is a single template that is used and it holds the message used to generate the comment left on the Trello card.:


By default the template contains the following:

Commit ```{{ changeset }}``` committed by {{ author }} with the message ```{{ commit_message }}``` - View at: {{ commit_url }}

The following is the context that will be passed to the template:

context = {
    'author': commit['author'],
    'author_full': commit['raw_author'],
    'changeset': commit['node'],
    'changeset_full': commit['raw_node'],
    'commit_url': urljoin(base_commit_url, commit['raw_node']),
    'commit_message': commit['message'],

the value of the “base_commit_url” variable is pieced together from data provided by BitBucket. It’s essentially “”. See BitBucket POST Hook Management docs for examples of what the JSON data looks like

Admin Actions

Also included is a simple Admin Action that makes it easy for you to re-populate one, or many, of your Trello boards via the Admin list page. Just select the boards you want to update, select the action, hit “Go”.

Example in Action

Here’s a simple screenshot from one of our development cards

Commercial Support

This software, and lots of other software like it, has been built in support of many of Netlandish’s own projects, and the projects of our clients. We would love to help you on your next project so get in touch by dropping us a note at

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django-trello-broker-0.3.tar.gz (12.8 kB view hashes)

Uploaded source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page