Skip to main content
Recursive link traversal in JIRA with ScriptRunner
Share on socials
Illustration of an issue in Jira
Jon Bevan
Jon Bevan
24th April, 2015
Data center icon
Server icon
Cloud icon

Recursive link traversal in JIRA with ScriptRunner

It's difficult to query issue links in JIRA to a depth greater than 1 when using JQL queries. Find out how ScriptRunner gives you recursive link traversal.
The latest release of ScriptRunner for JIRA Standard contains an exciting new feature the ability to traverse issue links recursively.
ScriptRunner for JIRA is a powerful add-on. It automates your JIRA experience and adds extremely useful features and functions. It can help you with workflows, JQL queries, automated tasks and much more.

Extending link traversal

For a long time it has been difficult to traverse issue links in JIRA to a depth greater than 1 when using JQL queries. The built-in function linkedIssues() does that well, but sometimes you might need to find all of the issues that are linked, both directly and indirectly.
For example, in the diagram you can see that if DEMO-1 blocks DEMO-2 we can find that out using linkedIssues(). However, if DEMO-3 blocks DEMO-2 we can't easily or quickly find out that DEMO-3 blocks DEMO-1 indirectly.
Other plugins have provided solutions to this problem by running recursive JQL queries, but the problem with that approach is that it can easily become a very slow process.

Using linkedIssuesOfRecursive() and linkedIssuesOfRecursiveLimited()

We've developed two new scripted JQL functions in the latest release of ScriptRunner for JIRA Standard. They give you recursive link traversal in JIRA, solving the problem outlined above.
Both functions use the internal JIRA APIs to do a breadth first search of all the issue links (direct and indirect ones) relating to the results of a sub query. These functions were based off the linkedIssuesOf() function already found in ScriptRunner.
The linkedIssuesOfRecursive() function is able to filter links by link type and direction. The linkedIssuesOfRecursiveLimited() function can also limit the depth of its search. By default, both these functions and linkedIssuesOf() traverse sub-task issue links.
For more information, check out the ScriptRunner for JIRA Standard documentation.

Try ScriptRunner for free

Ready to automate your JIRA experience? Try ScriptRunner today with a free trial.