Skip to content

aljungberg/flowdock-git-hook

 
 

Repository files navigation

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.

Commit URLs

Commit SHAs links in the Team Inbox of Flowdock can be made clickable to view the change on the web. To configure the URL for viewing commits, configure a ‘commit-url-pattern`:

$ config flowdock.commit-url-pattern "http://example.com/mygitviewer/commits/%s"

The %s will be replaced with the commit SHA.

Example for Redmine:

$ git config flowdock.commit-url-pattern "http://developer.example.com/projects/myproject/repository/revisions/%s"

Replace ‘myproject’ with the project the Git repository is associated with.

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": "raine.virta@nodeta.fi",
        "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"
  }
}

About

Git post-receive hook for Flowdock

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Ruby 99.1%
  • Perl 0.9%