Redmine に Webhook を追加するプラグインを作った

Redmine のチケット作成・更新にフックして、他のサイトに HTTP で POST する機能を追加するプラグインを作りました。

https://github.com/suer/redmine_webhook

機能

プロジェクト毎に POST する先を指定できます。

こんな感じの JSON が POST されるようになります。

{
  "payload": {
    "issue": {
      "author": {
        "icon_url": "http://www.gravatar.com/avatar/example",
        "identity_url": null,
        "lastname": "user",
        "firstname": "test",
        "mail": "test@example.com",
        "login": "test",
        "id": 3
      },
      "priority": {
        "name": "normal",
        "id": 2
      },
      "tracker": {
        "name": "bug",
        "id": 1
      },
      "parent_id": null,
      "root_id": 191,
      "closed_on": null,
      "updated_on": "2014-03-01T15:17:48Z",
      "created_on": "2014-03-01T15:17:48Z",
      "description": "I'm having a problem with this.",
      "subject": "Found a bug",
      "id": 191,
      "done_ratio": 0,
      "start_date": "2014-03-02",
      "due_date": null,
      "estimated_hours": null,
      "is_private": false,
      "lock_version": 0,
      "project": {
        "homepage": "",
        "created_on": "2013-01-12T11:50:26Z",
        "description": "",
        "name": "Test Project",
        "identifier": "test",
        "id": 4
      },
      "status": {
        "name": "new",
        "id": 1
      }
    },
    "action": "opened",
    "url": "https://example.com"
  }
}

環境

Redmine 2.4

インストール

1. 以下のようにプラグインをインストールする。

$ cd $RAILS_ROOT/plugins
$ git clone git://github.com/suer/redmine_webhook.git
$ rake redmine:plugins:migrate RAILS_ENV=production

2. Redmine を再起動