Most modern software project management systems provide functionality which allows to comment issues/tasks with special syntax in commit messages.
For example, Redmine does it quite well and additionally allows to log time to issues.
Github also provides great integration between issues and commits. What if we want to use other systems and still take benefit of everything Github offers?
Github prepared webhooks which allows to send rich JSON information on each push to any web service.
In the example below I’ll use Github webhooks to create Service Hook which posts comments on Trello cards.
As stated in Trello’s help:
What is Trello?
Trello is a collaboration tool that organizes your projects into boards. In one glance, Trello tells you what’s being worked on, who’s working on what, and where something is in a process.
With GitHub webhook it is possible to provide third party web applications with information about events in your repository such as new push or commit comment.
Webhooks are extensively documented on GitHub developer website.
Trello API allows to control everything on your Trello boards. Please, see Trello documentation.
Rails Web Service
Setup your own hooks
To use deployed example follow these steps:
- Create account and fill up all details necessary to connect with Trello: 1. Sing up at tgh.herokuapp.com.
- Edit your profile and request API key.
- Copy your API key from Trello website to your profile.
- Now, on the profile page, Request Token.
- Allow and Update Token.
- Create new repositories. 1. As name provide full name of your repo: username/repository-name (like in Gemfile).
- Go to repository settings on Github and provide app URL in Service Hooks -> WebHook URLs: http://tgh.herokuapp.com/push
- Create new boards and link them with matching repositories: 1. Open the board you want to use; in this example we’re going to use https://trello.com/b/2vlTljJN/playground.
- Create new board. As an UID type the id from the address: 2vlTljJN. As a name you can type what you want but board name is preffered: playground.
- Choose repository which is going to be described by this board. In the example we used mknapik/playground
Now your profile is ready to post comments on your Trello boards.
Each card on the board has number id which is unique within the scope of the board. Use this id in git commit’s message and a comment with link to the commit will be posted on this card.
Currently basic authorization was implemented but it was not tested sufficiently. It is recommended to use tokens with short expiration time only, clear them from the system or revoke them on Trello website after playing around with the app.