Flowdock Git Hook

Git Post-Receive hook for Flowdock

Installation

First, you need to install this gem. You need to have Ruby 1.8.6 and Rubygems installed in your system.

$ gem install flowdock-git-hook

Then, download the post-receive hook file to the hooks directory and make it executable

$ wget -O hooks/post-receive https://raw.github.com/flowdock/flowdock-git-hook/master/post-receive
$ chmod +x hooks/post-receive

Configure your Flow API tokens to git configuration

$ git config flowdock.token <Flow API token>

After this, you should get updates from your git repo every time you push to it.

Advanced usage

The git hook allows Flowdock tags to be attached to push messages. If you only need static tags, e.g. git repo name as tag, this can be configured in git config:

$ git config flowdock.tags git,push

For programmatic control over tagging, you can change how the hook is called in post-receive hook file.

Flowdock::Git.background_post(ref, before, after, :tags => ["git", "push"])

Note that you can also define token as parameter allowing multiple Flows to be notified.

Flowdock::Git.background_post(ref, before, after, :token => "flow-token")
Flowdock::Git.background_post(ref, before, after, :token => "another-flow")

Example data

The hook uses GitHub webhook format.

payload {
  "after": "122b95a8808ea0cf708fb43b400a377c25c35d7f",
  "before": "2a445d1d348d9d45217cb9c89c12b67d3767ce42",
  "commits": [
    {
      "added": [],
      "author": {
        "email": "[email protected]",
        "name": "Raine Virta"
      },
      "id": "122b95a8808ea0cf708fb43b400a377c25c35d7f",
      "message": "yeah!",
      "modified": [
        "TEST_FILE"
      ],
      "removed": [],
      "timestamp": "2010-08-11T13:46:39+03:00"
    }
  ],
  "ref": "refs\/heads\/master",
  "ref_name": "master",
  "repository": {
    "name": "testrepo"
  }
}