Bethany Minor
Bethany Minor

Reputation: 57

Programming JIRA to show # of bugs and calculate time spent

I would like to program a filter in JIRA to show the number of bugs for a sprint and also calculate time spent. I have tried a number of the current reports but they do not automate this calculation. Has anyone successfully done this? I would prefer to do this via JQL rather than using the API.

Upvotes: 2

Views: 1195

Answers (2)

Somaiah Kumbera
Somaiah Kumbera

Reputation: 7539

@GlennV is right - JQL is not SQL, and it returns only issues, not issue fields.

If you have the plugins he mentions, you should follow his guidelines.

If not, using the REST API gets you exactly what you need, even if you're loathe to use it :)

For my project key "MRL", I called:

https://my-jira-server/rest/api/latest/search?jsql=project=MRL%20AND%20issuetype=Bug

This returned a whole bunch of JSON info which I can then parse to get only the timeSpent field

If you're lucky enough to be on linux, you can use jq to quickly count the hours with this filter:

[.issues[] | .fields | select (.timespent != null) | .timespent] | add

If you want to try it, copy the entire JSON you got when you ran the REST API (the searchjql link), go to https://jqplay.org/, paste it into the JSON field, and paste the filter into the filter field.

I wrote a blog about something like this which you might want to refer to:

http://javamemento.blogspot.no/2016/05/jira-confluence-3.html

Upvotes: 1

GlennV
GlennV

Reputation: 3670

With the standard JIRA functionality, the "issue search" page does not offer you a way to summarise values (yet).

There are a number of add-ons that can help you accomplish this though, for example:

sumUp

There is the sumUp add-on which does exactly that and is probably the easiest option.

Script Runner

You could also use Script Runner and its aggregateExpression JQL function, which supports "time spent" and other time fields and can give you a view like this: enter image description here Script Runner also has a ton of other useful features to customise JIRA.

Pivot Gadget

And if you're looking for a gadget to add on a dashboard instead, you could also use the Pivot Gadget add-on. This one supports pivot tables and can sum up totals, so you get something like this: enter image description here

No Add-Ons Possible: Use the JIRA REST API

If installing add-ons is not an option, then you can still script a solution using JIRA's REST API. Especially the search resources will be useful.

You can use any kind of programming or scripting language to build this. There's already another answer that explains how to do this with bash, but if you google you will also find JIRA REST client libraries for java, python, ...

Also, most programming languages have very good REST support, so use whatever you are familiar with.

Upvotes: 2

Related Questions