2 min read

Recursive link traversal in JIRA with ScriptRunner

JB
Jon Bevan
Fri, 24 Apr 2015
Recursive link traversal in JIRA with ScriptRunner

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 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.

Usng 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. To start using it to automate your JIRA experience, download it free from the Atlassian Marketplace.

 


Stay up to date by signing up for monthly Adaptanews