How to find stories in a set of epics?

Jon Abad July 21, 2013

Hi all,

In JIRA 5.1.3 /GH 6.2.4.1, I would like to find "all stories linked to the epics assigned to me" or as another example "all stories linked to the epics within a component".
In this scenario, we are using the GH provided Epic Link field and not the standard jira linked issues functionality.

I started writing this out as:

project = code AND "Epic Link" in (project = code AND type = epic and assignee=currentuser())

This fails with the following error:

Error in the JQL Query: Expecting ',' or ')' but got '='. (line 1, character 44)

Looking at the Epic Link field, it happily takes the IN operator and am able to manually build a set of epics or use a function like votedIssues() or watchedIssues() but no way to pass another query or filter.

Has anyone solved this in JQL or with add-ons?

8 answers

1 accepted

4 votes
Answer accepted
JamieA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 28, 2013

Try reading Nicholas Muldoon's post here...http://www.nicholasmuldoon.com/2013/06/using-the-epic-workflow-in-greenhopper/

For a first step, you can get the stories of unresolved epics with:

issueFunction in linkedIssuesOf("issuetype = Epic and resolution is empty", "is epic of")

(linkedIssuesOf docs).

Jon Abad July 30, 2013

Thanks Jamie!

I wasn't aware of the "is epic of" relationship type and figured i was just limited to the jira relationships, causes, blocks etc.

Wolfgang Winzer August 28, 2020

Thanks, that worked for me. Now, 7 years later, you can also use the more specialized issuesInEpics function of ScriptRunner. See my answer below for details.

Like Piotr Nadworski likes this
10 votes
Alain C. Boss November 13, 2015

First you create a filter for your epics as desired --> My Epic Filter

You can then use the issuefunction. Because the filter contains whitespace, you have to quote the name and because it is used within double quotes you have to use single quotes.

issueFunction in linkedIssuesOf("filter = 'My Epic Filter'", "is epic of") OR filter = "My Epic Filter"

With the OR-part you will get the epics as well.

 

Novita Aryani February 6, 2016

This works for me too! Thanks !! 

Joey March 15, 2019

took me an hour to find the right filter but this works!

Matt Hudson November 7, 2019

This worked great! Thanks so much for this tip!

Ragni Jayanthi March 3, 2021

Worked for me as well. Thank you

3 votes
Jon Abad July 28, 2013

The way i'm doing this for now is to manually build out the set for EPIC LINK to accept:

project = code AND type=story AND "Epic Link" in (CP-123, CP-1234, CP-12345)

Depending on how often we have to do this, I may put together an excel workbook that gets the list of issue ids via the REST ws but I expect that the copy & paste approach will win out for a while.

Swarna Nalluri May 29, 2020

I needed an export of all the stories and tasks in a epic, and this was perfect, and exactly what i was looking for!

3 votes
Timothy
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 21, 2013

"Epic Link" takes a list of values. It can't take another JQL.

You could try:

project = GreenHopper AND "Epic Link" = GHS-9520 and issuetype = "Stories" and assignee=currentuser()

Jon Abad July 23, 2013

Timothy,

I see that "Epic Link" will take a single issue or a list of issues but i'm looking for a way to generate that list based on a filter, JQL or function.

Like Yolanda Brown likes this
1 vote
Wolfgang Winzer August 28, 2020

If you have ScriptRunner 5.6 installed, you can use issuesInEpics like this:

project = code AND issueFunction in issuesInEpics("project = code and assignee=currentuser()")

 issuesInEpics is slightly more convenient than the more generic "issueFunction in linkedIssues".

0 votes
tomcwalker September 3, 2018

Regrettably, the "out of the box" JIRA doesn't support this functionality. If you want to find all items belonging to Epics pulled back from a query, you will need a plugin. 

As the ScriptRunner plugin adds over 35% to the cost of a basic JIRA cloud, we use JQL Search Extensions for JIRA instead - it's about 1/3 the price of ScriptRunner.

https://marketplace.atlassian.com/apps/1214791/jql-search-extensions-for-jira?hosting=cloud&tab=pricing

They have examples showing how to do the kind of thing you ask here: 

https://jqlsearchextensions.atlassian.net/wiki/spaces/SEARCH/pages/173211649/Subqueries+-+JQL+Search+Extensions+for+Jira+Cloud

In particular, see the "issuesFromEpicsInQuery" documentation.

0 votes
Jennifer McVicker January 22, 2016

This worked for me:

issueFunction in linkedIssuesOf("issuetype = Epic and component IN (MyComponent)", "is epic of")

...now if I can just figure out how to pull in the subtasks for the stories in those epics...

0 votes
Jon Abad July 21, 2013

Addendum:

This would be similar to the view that one gets in the Agile Board, Plan View when clicking an Epic Name.

I am trying to get the items that are shown in the Sprints or Backlog in JQL.

Suggest an answer

Log in or Sign up to answer