Returning only highest level result using JQL

Anthony March 26, 2018

Apologies if this has been asked before - I've searched but am struggling to find a similar example and would appreciate some help. I'm pretty new to jira. 


My company uses the epic/theme field in jira to mark certain types of work. Sometimes this tag is applied at an epic level, and other times it is applied at a story level (within an epic that does not contain the epic/theme criteria needed)

In the structure below, the Y/N refers to whether or not that epic or story is marked by the necessary epic/theme

Epic 1 (Y)
- story 1 (Y)
- story 2 (Y)
- story 3 (N)


Epic 2 (N)
- story 1 (Y)
- story 2 (N)
- story 3 (N)

 

My question: Is it possible to write something in JQL that would return only the highest level instance of a particular epic/theme? 

Given the example above, the result that I'd like to bring about would only have two results:

1. Epic 1 (epic only, do not return stories)
2. Epic 2 Story 1 (story only, do not return the epic)

 

2 answers

1 accepted

1 vote
Answer accepted
Alexey Matveev
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.
March 26, 2018

You would need to develop your own JQL functions, either by Power Scripts or ScriptRunner plugins

1 vote
Egor Tasa [ALM Works]
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.
March 27, 2018

Hi Anthony,

What you mention can be accomplished by S-JQL in our Structure app, if you are open to try a new app. S-JQL - short for "structured JQL" - combines issue's position within a hierarchy with filtering by its attributes.

In the Structure you can build a hierarchy for your use case the following way:

  1. Create a new empty Structure (from Structure menu)
  2. Add an inserter (Automation+>Insert>JQL Query) with JQL issuetype=Epic (for example)
  3. Add an extender (Automation+>Extend>Stories under epics)

You will have a two-level structure with Stories appearing as children of Epics. Then you can use the following S-JQL statement (in Advanced Search) to seek for issues tagged as you have described: issue in structure("StructureName", "[tagName='Y']") StructureName here is what you called your structure during creation, tagname='Y' - the criterion you mention in your question. 

You can try out Structure in our sandbox environment and see if you find anything else that catches your fancy. I am open to answer your questions and even provide a walkthrough if needed.

Regards,
Egor Tasa
ALM Works

Suggest an answer

Log in or Sign up to answer