9

Is it possible to use raw JQL (not using any plugins) to filter for ALL stories AND their respective sub-tasks?

Currently, I have the following which successfully retrieves all stories for EPIC-123:

project = PROJ1 AND "Epic Link" = EPIC-123 AND issuetype = Story ORDER BY priority DESC, updated DESC

However, I also want the sub-tasks related to those stories. So I thought this would work:

project = PROJ1 AND "Epic Link" = EPIC-123 AND (issuetype = Story OR issuetype = Sub-task) ORDER BY priority DESC, updated DESC

But this only returns the stories.

I think this is because JIRA reads this as "Retrieve sub-tasks for EPIC-123" (which is 0) as opposed to "Retrieve sub-tasks for stories in EPIC-123".

I also thought about using issue in (linkedIssues(AAA-###)) but I imagine this will involve programatically looping through all the stories that are returned in the above query. Which seems ridiculous and probably not possible.

Would rather not go down a plugin path but open to suggestions. Thanks!

pele88
  • 802
  • 2
  • 8
  • 16
  • You can filter either parent issues or sub tasks. So you can get parent issues which have sub tasks meeting certain criteria, or you can get sub tasks whose parent issues meet certain criteria. For example there is function "issueFunction in subtasksOf..." which will return sub tasks based on parent task data .. and it is part of Script Runner plugin. – Robert Feb 08 '16 at 11:28
  • @Robert Sounds good, not sure how to put that in JQL though. Could you provide some example JQL please? – pele88 Feb 08 '16 at 11:40
  • Also, been tinkering with the idea of just assigning everything to a label and doing `project = "PROJ1" AND labels = label-123 ORDER BY priority DESC, updated DESC` . Any negative repercussions to that? – pele88 Feb 08 '16 at 11:42
  • I don't recommend labels as they are very informal and user can change them, create new etc... For issues that have Epic you can do: issueFunction in linkedIssuesOf("", "has Epic") with optional subquery as a first parameter. Or the other way around as: issuefunction in linkedIssuesOf("", "is Epic of"). For subtasks you could use the functions above. I'm not sure what exactly you're trying to do, can you be more specific? You can't have tree relationship as an output of JQL so you have to separate it into multiple queries. – Robert Feb 08 '16 at 14:11
  • @Robert I basically want to be able to branch off entire Epics and it's respective stories/sub-tasks to a completely new board. This is to separate Client A from Client B from viewing unrelated stories/tasks. – pele88 Feb 08 '16 at 15:39
  • Then you can use this: issueFunction in linkedIssuesOf("subquery", "has Epic") and the subquery would specify epics you're interested in. That will give you relevant issues that belong to that epic. You need to distinguish epics somehow based on clients. – Robert Feb 08 '16 at 16:00
  • @robert I can distinguish epics/clients fine. Is issueFunction part of the standard JQL? I am seeing this error now `Field 'issueFunction' does not exist or you do not have permission to view it.` – pele88 Feb 09 '16 at 08:12
  • No it's part of Script Runner plugin (there is also free version) – Robert Feb 09 '16 at 08:15
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/102973/discussion-between-pele88-and-robert). – pele88 Feb 09 '16 at 08:46
  • @pele88 were you able to find a solution for this? facing exact issue here for same scenario – blazR Jul 26 '21 at 17:58

6 Answers6

5

As of 13 January 2017, Jira Cloud support parentEpic that does exactly what you are asking for. You can use it like:

parentEpic = EPIC-123

and this will find the EPIC-123 itself, plus all the issues assigned to the epic and their sub-tasks.

enterbios
  • 1,725
  • 12
  • 13
2

This worked for me.

"Epic Link" = JIRA-123 or Parent in ("JIRA-123")
Erwin Alberto
  • 1,064
  • 10
  • 7
  • 1
    In 2022 the first part of this is the only answer that worked for me. ("Parent in" did not work) I discovered this by going to Reports -> Epic Report -> "View in Issue Navigator", which automatically takes you to the JQL with the above ("Epic Link"). – Michael Liquori May 13 '22 at 18:50
1

parentEpic wasn't working for me, but I figured this out using childIssuesOf! I hope this helps someone still looking for an answer on this:

"Epic Link" = EPIC-123 OR parent in childIssuesOf("EPIC-123")

The first half of the query gets all the Stories, Tasks, and Bugs of the Epic, and the second half of the query gets you all the subtasks of the Epic.

LHM
  • 721
  • 12
  • 31
0

The function issuesWhereEpicIn() is available as of v5.2:

issue in issuesWhereEpicIn("issue = JIRA-1234”)
OR
parent in issuesWhereEpicIn("issue = JIRA-1234")
Brian Pan
  • 144
  • 1
  • 8
  • 1
    Forgot to mention I'm using Jira cloud. If the above is part of the JQL tricks plug in then I can't install that onto the cloud version. – pele88 Feb 11 '16 at 10:12
0

You can query all stories/tasks/subtasks/defects/etc, related to EPIC-123 plus that epic itself using the following JQL:

parentEpic IN (EPIC-123)

You can have multiple Epics in the query:

parentEpic IN (EPIC-123, EPIC-456)
Petr Lazarev
  • 3,102
  • 1
  • 21
  • 20
0

I use:

parentEpic = AB-12345

or:

parentEpic in (AB-12345, AB-67890)
m4n0
  • 29,823
  • 27
  • 76
  • 89