JQL: Find the latest closed sprint - jira

How can I find the last closed sprint?I tried using
ORDER BY updatedDate DESC
but this returns all the closed sprints. I need only the latest one.

JIRA does not provide a JQL function out of the box that supports listing the issues in the last completed sprint. The best it offers is displaying the issues in a sprint by name, e.g.:
sprint = "<sprint name>"
You can find the documentation about the JQL support for the sprint field here.
If you use JIRA standalone, then there are a few add-ons that provide additional JQL functions. For example, Script Runner adds a function previousSprint that does what you want. Your JQL then looks like:
issueFunction in previousSprint("<board name>")
There is also a cloud version of this add-on, but it does not support the agile functions yet. To see what they do support, check this table.

Related

JQL query to filter JIRAs based on the last commented date by a particular account / user

I am new to JIRA / JQL, and wanted help in knowing if the following is possible:
I want to filter JIRAs which have been commented on by a particular user (a bot account) in the past xx days
I want to filter JIRAs which have a particular regex in its comments in the past xx days
If the above cannot be done, I am open to suggestions as to how to achieve it using a combination of labels and description in the JIRA!
Sorry, but comments are stored within each Issue and you can't search for them globally using the native JQL query. You'd need to utilise the REST API to iterate through the Issues, extracting all the comments, then filtering the results.
Refer to this article in the Atlassian community Jira blog on the same topic and what third party tools can help work around the issue.

How do I get the number of bugs reported per month on Jira?

I am new to Jira and am trying to find the number of bugs reported on Jira per month using JQL query.
In fact you could use the basic mode in Issues tab, to arrive at the report
Basic mode generates the JQL in the background with help of dropdowns and selections, Advanced lets you use the JQL
Requested JQL Query Below, for Month November
project = *YourprojectName* AND issuetype in (Bug, "Story bug") AND created >= 2018-11-01 AND created <= 2018-11-30

JQL to get blocked Issues

Is there a native JQL (not a plugin) that returns tickets that have linked issues listed as "is blocked by" (so I can see all my blocked tickets).
All I have found is linkedIssues() but that can require a specific issue ID to search for which is entirely unhelpful.
I am using Jira Cloud 7.4.
In the core JIRA JQL functionality the closest thing you have, as you've already found out, is linkedIssues() that requires a parent Issue reference.
What you need is Adaptavist ScriptRunner, they have a function called hasLinks(). There are also a handful of other add-ons that offer this functionality but like ScriptRunner, they all cost money.
Related JIRA community question
JIRA Cloud feature request
The below query is also helpful (add it in the filter setup):
project = "Project ID" AND issuetype in (story, Spike) AND Sprint = "Sprint ID" AND linkedIssue in issueHistory()
According to Esther Strom's answer on this Atlassian site, there's a new query type:
Atlassian has very recently introduced a new JQL function called issueLinkType, which can be used in filters, but also in boards.
It's not perfect; if you're already using card colors for something else, you won't be able to use this as well. It also behaves inconsistently when a ticket has links of multiple types. But if you're looking for an easy way to get a view into what might be blocked, and what might have blockers, it works pretty well.
In KQL you can specified the type of link.
For what you want to do here what you can use
issue in linkedIssues([Issue#],"is blocked by")

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.
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:
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:
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.
#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

retrieving maxResult in worklogs using jira JQL issue

I have a simple jql query that gives me all the issues and work logs. The worklogs however seem to cap at 20. How can I force it to retrieve all ? E.g
http://website/rest/api/2/search?jql=project in (Project) and issueFunction in workLogged("after 2015/10/12 before 2015/10/17") &startAt=0&maxResults=1000&fields=worklog
How can I force that the max results for work log is for example 100 instead of 20. I am unable to find any references on how to change the max when it is inner node.
At the moment you cannot force Jira to return all worklogs. The 20 cap is a known issue at Atlassian and awaits fixing. News can be found at the bug ticket:
https://jira.atlassian.com/browse/JRA-34746
There are possibilities to use SQL to query your Jira database for the worklog data:
Directly, which can be considered deprecated because of the risks:
"Zero security ... could potentially slow the Jira system access ... inefficient queries"
Via a third-party plugin
" 'SQL for JIRA', a new plugin for JIRA which supports standard SQL against the JIRA API"
https://answers.atlassian.com/questions/17373/can-i-acess-the-jira-database-to-run-my-own-querys
I can't guarantee that either works for you but it is a starting point until the bug is fixed.
I had the same issue and I could get all the worklogs separately without any maxResult limits using the following link:
../rest/api/2/issue/your_issue_id/worklog/

Resources