Creating daily status updates email from JIRA

09 Feb 2016 •

Context

My client has always preferred reading an email at the start of his day that summarizes all the work his dev team was up to the night before. We call it the status mail. It usually contains the list of tasks we have worked on, containing its full description along with our comments/status on that day. Such reports are favorites among clients who are non-technical or who cannot afford to spend time in JIRA, as they get all updates in one go. But, of course, this is beneficial only for a team size of 5-20 members. Any more than that, the mail itself becomes too long to read.

Background

We adopted JIRA only recently, slightly more than a year ago. During the pre-JIRA dark ages, my predecessors had to perform a laborious task of compiling status mails from tasks, bugs and feature requests sent by the clients over emails. It used to easily take up 30-60 mins on a rainy day, copy pasting updates provided by the team, then mix-matching the formats to make it look good, etc. Moreover, it was too much manual labor to love this part of the job.

Then came JIRA, and life became much more efficient.

Creating Status Mail from JIRA

So, let us get down to the core part of this post. The steps to create a status mail are pretty straightforward. But before we proceed further, go through the checklist below that you may need (to know).

The Secret Ingredients List

  1. JQL (JIRA Query Language) to build your query
  2. JIRA API to fetch the query results programmatically
  3. An application+ to fetch your results using JIRA API
  4. JavaScript and JQuery+ to process the result (final JSON)
  5. JQuery templates+ to build your email content (HTML) from your processed final JSON.

[+]: Choose language or tool of your choice.

JQL

First and foremost, you need to fetch only relevant issues that have been updated that day to be processed and put into the status mail. JQL (JIRA Query Language) is the best way to get that done. A typical example of the query I use is as follows.

project in ("My Project") AND comment ~ "\\[statuscomment\\]"
    AND updated > startOfDay() AND updated < endOfDay()
ORDER BY key DESC

NOTE

JIRA API

To fetch issues from JIRA in to your application, you need to use /search API. You can use either GET or POST method to do so. The JIRA documentation explains all necessary steps clearly, so I’m not covering that. However, here are the key parameters that you should add to fetch all necessary details in one go.

{
    "expand": "names,schema,renderedFields",
    "jql": "our JQL query mentioned above",
    "fields": "summary,description,comment"
}

Here is a sample JQL result-set.

There are a few key things to note in this result set:

Process Result

processStatus(data) function in below jira-task-status-processor.js gist is our public API to building the status HTML. What it essentially does is:

  1. Process result set per issue-item per comment
  2. Check that the comment must begin with [statuscomment] – else do not process
  3. Check that date of comment must be after checkDate passed (checkDate defaults to today) – else do not process
  4. Strip out [statuscomment] tag from comment, as not required anymore
  5. Prepare an object containing issue title, description, filtered comments content, user details of comments, etc.
  6. (Freebie) Encode comments so that we can put it into email replies automatically when Repy > button is clicked. (See further sections below to understand what I’m talking about)
  7. Pass object to JQuery Templates (see jira-status-template.html gist) that builds the final status mail HTML.

And here are the jQuery templates used to generate the HTML.

NOTE

Final Output

Combined together with the JIRA API result-set, you may generate an HTML which finally looks like the following image. Of course, this is a very crude representation below without any styling whatsoever. So, please do stylize the output as you like, before sending it to your boss. ;)
Final status HTML

And here is the gist of it:

Ending Note

It took a few weeks for the team to get used to JIRA’s markdown syntax, but once they got the hang of it, life has been harmonious for everyone.

The output generated out of this exercise (content inside div-final-html) has saved me 30 minutes every single day, since Jan 2015, which could be then utilized for other interesting things, like improving project design, get more time to connect with team members or simply go home early on lazy days. :D

And that’s how I saved time.