JIRA JQL - Find issues with more than X days in Status - jira

I want to show all issues where it has been in a current status for more than X days - is this possible?
We have this workflow: Registered => Analyze => Planned ... etc. The ticket can be in Registered for 3 weeks and it can be 3 weeks in Analyze without any problems.
Currently I am using this JQL to show tickets that have been more than 3 weeks in Analyze:
project = MyProject AND status = Analyze AND created <= -6w
This is wrong due to so many reasons and it does not look at the time in the current transition state - nor does it take in to account that it can be pushed back from Planned to Analyze and then allow a new 3 weeks analyze period.
Is the above possible to filter in JIRA? I don't have the possibility to use the JIRA REST interface - only the builtin JQL.
I am running with JIRA version 6.4.5.

You should be able to get there using the JQL CHANGED operator. Its documentation is available here.
Your query would look something like this:
project = MyProject AND status = Analyze AND status CHANGED BEFORE -3w

If you want to know for what day range the issue was lying in a status and when status are consecutive, for example a UX review will happen before QA starts working on it and I want to know the issues which are lying in UX review for more than10 days then my JQL can be
project = *your project* AND status changed to "Ux review" before startOfDay(-10) AND status changed from "UX Review" to "Ready to test" after startOfDay()

project = MyProject AND status = Analyze and not status changed during (-xd,now())

With Script Runner plugin I'd create a new scripted field that would just return the number of days since the last status change, with a Number field template, and Number Range Searcher. The
def items = com.atlassian.jira.component.ComponentAccessor.changeHistoryManager.getAllChangeItems(issue).findAll{it.field=="status"}
will return ChangeHistoryItems for Status field. Take the last one and use its getCreated() to find Timestamp. If the list is empty, it means that the issue is in the first step of the workflow, use its issue.getCreated(). Test. Re-index. Search. Use.

Related

Jira JQL operator and + and + and

please I want to create a filter of custom statuses, but somehow when I press search I will get no results. When I search only for one status all is fine, but I want to merge that somehow into one filter. Or is there any way to get a exact number of tasks in any kind of status, assigned to the user? Im using the pie chart and want to see the number of all tasks assigned for any guy in the team, no matter the status. And I want to have it in a gadget. Thanks
Code Im using is:
project = "XYZ" AND status = "To Do" AND status = "Awaiting Approval"
AND status = "In Progress"
Have you looked at the 'in' operator?
...AND status IN ('To Do','Awaiting Approval','In Progress')
A Jira ticket cannot have more than one status at the time. I would do something like this
project = "XYZ" AND status IN ("To Do", "Awaiting Approval", "In Progress")
The other answers are definitely the correct way to write the JQL you were aiming to write, however I believe there is a better solution to your actual aim.
From what I understand, you want to see any Jira issue which is not closed and is assigned to a particular user. In this case I think the best solution would not to find all issues in the specific "open" statuses, but instead to find all which are not closed.
The best way to do this is by filtering by the status-category, as this will ensure the JQL works for all workflows, regardless of what their done/closed statuses are called.
statuscategory != done AND assignee=<user>
Replace <user> with the user you want to filter for, or currentUser() to automatically get the user who is running the query.
Documentation (only mentioned briefly): https://support.atlassian.com/jira-software-cloud/docs/advanced-search-reference-jql-fields/#Advancedsearchingfieldsreference-ResolutionResolution

JQL: Putting function instead parameter

For now i'm using such query:
project = MyProject AND issueFunction in addedAfterSprintStart("General
Board", "MyProject-20180903")
After each sprint I need to change 2nd parameter, to last sprint, I want to avoid it, i tried with:
project = MyProject AND issueFunction in addedAfterSprintStart("General
Board", previousSprint(General Board))
but it's not working.
Is there possibility to use function as a parameter, if no, how can I get the same result other way?
Are you trying to get the issues added after the start of the current opened sprint ? If yes you should just omit the second parameter of the addedAfterSprintStart function.
issueFunction in addedAfterSprintStart("Scrum Board Name") return all issues added after start of current opened sprint
See documentation : https://scriptrunner.adaptavist.com/latest/jira/jql-functions.html#_addedaftersprintstart
If you want the issues added to a closed sprint i don't think is is possible with the addedAfterSpintStart function.
But you may find this information on the sprint reports : https://confluence.atlassian.com/jirasoftwarecloud/sprint-report-777002722.html

Get all JIRA issues that have been worked on in the last X hours

I need a JQL query, that shows me all issues, that have been worked in since X hours.
I can find in JIRA, to get all resolved issues in the last X hours resolved >= '-1h' or created created >= '-1h', but don't find any to get those, that have been started to work on.
So there is the status field, that switches from "OPEN" to "IN PROGRESS", which is the progress I'm interested in.
I tried updated >= '-1h' AND status in('IN PROGRESS') AND status was in('OPEN'), but the status was does not take the updated into account, which means, I do also get an issue back, that has been updated with something in the last hour, but the status change was done way longer ago.
So how can I get the issues, that had the status change in the last X hours ?
You're looking for the CHANGED operator. Its documentation is available here.
You can use a query like:
status changed TO "In Progress" AFTER -4h

How to configure a custom field with auto increment value?

I have a jira workflow which going in loop, if certain transition execute as "solution failed".my problem is I need to count how many times a ticket got "solution failed".is there anyway I can achieve this?.and also this count need to be view in a ticket as well.
Initially I created a custom field and attached to relevant screens in the workflow.then after that how can I count the times that the ticket going through a certain transition.this field should be updated automatically.
With Script Runner you may create a scripted field that will just count relevant changeItems. This is example to count how many times an issue has been put into Closed status.
import com.atlassian.jira.component.ComponentAccessor
def items = ComponentAccessor.changeHistoryManager.getAllChangeItems(issue).findAll{it.field=="status" && it.getTos().iterator().next().value=="Closed"}
items.size().toString()
JIRA itself won't be able to do what you are planning. You'll have to use an addon, probably ScriptRunner or JJupin. You can use the last free release of ScriptRunner to avoid the commercial license.
More info here https://answers.atlassian.com/questions/266510/script-to-increment-value-of-custom-field-in-post-validation-condition

How do I query Jira to search for all issues in a project for which no user has logged work in last week?

I need a way to get all the issues (which are not resolved or closed) of a particular project for which no user has logged work in last week.
For example, let's say I have a project = 'abc' with five issues 'i1', 'i2', 'i3', 'i4' and 'i5' and there are two users 'u1' and 'u2' who can log work in these issues.
Last week - 'u1' logged work in issues 'i2' and 'u2' logged work in issues 'i2' and 'i3'.
So the desired result is - 'i1' and 'i4'.
Something like
project = ABC and status not in (Resolved, Closed) and worklogDate > startOfDay(-7)
should work.
You can do this by installing the Script Runner plugin and using JQL to query for workLogged information:
project=ABC and status not in (Resolved, Closed) and issuefunction not in worklogged("after -7d")
If you need to do fancier queries based on the attributes of the users and so forth, see the commented() documentation for reference.

Resources