Bitbucket2asanaWe at Five Minutes work on projects of various sizes and complexities. But since we are primarily a mobile development shop, often the projects last for just a few months and they overlap in different stages. To be able to manage and track these kinds of projects we need powerful but also simple and effective tools.

We like to experiment, so we tried different tools like Trac, Pivotal Tracker, Microsoft Project, Jira, Asana, Trello, Bitbucket Issues and others. Some of these were used individually, others in a combination. My team chose a combination of Asana and Bitbucket Issues. Asana is awesome for managing smaller projects, especially if they tend to overlap. But it lacks the features of an issue tracking system. And since we already used Bitbucket for source control, naturally we chose Bitbucket Issues for issue tracking. So in combining these two, as you can imagine, we found that having the tasks distributed on two different systems makes task management difficult and causes tasks to be overlooked and left behind. If only issues assigned to a person would automatically appear in their Asana task list.

Hackathon we had recently was a great opportunity to explore this idea further. While my other colleagues immersed themselves in cool projects which include hardware related stuff like presence detection and triggering door buzzer with a mobile app, I was eager to solve somewhat less “fun” problem which bugged us in our everyday work. There ought to be a simple way to connect these two services, I assumed.

In my mind, there was a perfect solution, a web service that would be connected to Bitbucket via “issue changes subscription API” similar to Facebook’s Realtime Updates API and to Asana via simple API for managing tasks. After some research, I found that Asana has an API, which makes it easy to create tasks on behalf of a user for which you have an API key. Great, second requirement – checked. As for the Bitbucket, it has both an API and a Broker service architecture, but none of those provide the ability to act on an event of an issue being assigned to the user. There is the Events resource which could be polled in intervals, but that would be useful only in theory, because in reality the resource doesn’t support private repositories. So, without any other ideas, there was one last option to explore – email notifications.

Bitbucket has one annoying feature, as a team account owner you can either turn on or turn off all email notifications. In case they are turned on, the account owner is going to receive a notification for every event in any of the repositories the team is working on. Otherwise irritating feature, turned useful in this case. While thinking about ways of pushing the email notifications from Bitbucket to my web service, it occurred to me that the whole thing could be simplified to an email processing script called on all incoming emails. Sudden realization followed by some furious typing and there was a working prototype. The script would be called on an incoming email notification from Bitbucket, email would be parsed, issue related data extracted and a new task would be created in Asana. After another coding session the system would also be able to receive configuration information (workspace identifier, Bitbucket usernames and API keys for individual users) via email so that there is no need for an admin interface of any kind.

After the coding was done, a dedicated email address was created to which all emails from Bitbucket were forwarded from the team owner’s inbox. That email address was configured to have Bitbucket2Asana script run on every incoming email. And the only thing left was to ask other team members to send their Asana API keys in a given format to the dedicated Bitbucket2Asana email address and they would have their Bitbucket issues appear in Asana as new tasks.

The source code of the Bitbucket2Asana system is available on Bitbucket.