Recursive link traversal in Jira with ScriptRunner
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 cant 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.
Usng linkedIssuesOfRecursive() and linkedIssuesOfRecursiveLimited()
Weve 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.