Hello, it’s Jeri here. In the earlier blog post I promised to tell something about our project management conventions.
For 6 months, we used Kanbanflow.com as our primary issue tracker from which we could easily see which tasks are currently on-going and which have been completed. We had a huge backlog of improvements, bugs and new features ready to be implemented. The tool has one major problem for us though: There is no possibility to link the issues to our Git repository.
April 1st I decided to change some things. I imported all the issues from Kanbanflow.com to a local JIRA server (which we now have on the 30 day free trial period). I was easily able to configure our Bitbucket repository to synchronize with our JIRA instance. Now we can use smart commit messages, such as “GOHAI-69: Implemented it as whole. #done”. That message would automatically set the issue “GOHAI-69” as “Done” in JIRA. That really helps ALOT.
Since we work separately and have over 300 kilometers distance between us, it is important to have good communication tools also. At first, we were using Steam for text based communication and Skype for voice communication. That wasn’t really convenient and we were having some quality issues with Skype so we decided to switch to using Discord instead. Discord features different channels for different topics, and has a voice chat feature built-in.
Now we lacked one more thing: JIRA / Bitbucket –> Discord integration. It is really good to have someone to notify you automatically when you got new tasks in the project management tool. This is why I decided to get a JIRA –> Discord bot. Until I realized there isn’t any available!
After a day of digesting I decided to start implementing one by myself. It took a while to get into the Discord API documentation. For JIRA I didn’t find any good documentation on the webhook interface so I decided to almost brute-forcefully just keep spamming various notifications on JIRA to my bot’s HTTP server. That way I was able to figure out enough information to build a working bot.
Both JIRA and Discord use JSON in the HTTP messages. I created a .NET console application that deserializes the JSON messages from JIRA, converts them to a Discord suitable format, serializes them back to JSON and sends them to Discord. Simple workflow. Easy stuff.
I left message text empty and set author icon and name properly. I used the JIRA event type, issue title and issue key as parts of the field title and generated a link to the issue as the field value using the issue key. Message icon URL is actually used as the bot’s avatar. I set it to match the Atlassian logo that can be found in the JIRA files (“JIRA_PATH/images/64jira.png”). Discord messages also can contain other fields but they were not necessary for our purposes.
For pure issue edits and creations, user field is used. For comments, the comment author field must be used.
I decided to implement the client-server application using C#. For the server I used NHttp which is an easy to use HTTP library for .NET. The client is HttpClient from the standard System.Net.Http library. The server is used to listen for events from JIRA and the client passes them forward to Discord. The JSON serialization is really easy to do using Newtonsoft Json library which can be found using NuGet package manager.
This is enough information so that you can implement a bot of your own. The text covers quite nicely both the JIRA API and Discord API. If you got any questions, just ask! Thanks for stopping by!
EDIT: By a visitor request we decided to add the C# source code for the bot server!
Just create a new C# Console Project in Visual Studio, paste this in and build. You’re welcome. 🙂
The code is a real bubble gum mess containing hacks & hard coded stuff. But it works for the purpose!
Download the source code here: Program.cs