Scheduled automation rules result in duplicate links or actions in Jira

Platform Notice: Data Center Only - This article only applies to Atlassian products on the Data Center platform.

Note that this KB was created for the Data Center version of the product. Data Center KBs for non-Data-Center-specific features may also work for Server versions of the product, however they have not been tested. Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.

*Except Fisheye and Crucible

Summary

Scheduled automation rules may result in duplicate issue links or actions if they use the "Branch rule / related issues" component — specially the JQL branch.

Example

Requirement: If two issues, A and B, have the same custom field value, link them together by "relates to". Expected results: A and B match, so the automation rule links them as A "relates to" B. Actual results: A and B match, so the automation rule links them two times: A "relates to" B and B "relates to" A.

Diagnosis

This solution proposed in this article is valid if all conditions below match:

  • The automation rule trigger is a Scheduled JQL

  • The automation rule uses the component "Branch rule / related issues"

Cause

When using "Branch rule / related issues", specially if JQL based, some issues may be present both in the trigger JQL and in the "branch JQL", causing the automation rule to execute the action more than once.

This is the expected behavior for the automation rule, though it may not be the original intention.

In the example at the beginning, both issues A and B are matched by the trigger JQL. On the branched JQL from issue A, B is matched — and in the branched JQL from issue B, A is matched. Thus the action is performed twice: from A to B and from B to A.

Solution

To prevent duplicates actions, you may insert a comparison before the actions to exclude issues based in some difference between the one currently matched by the trigger JQL and the one from the branched JQL.

The example below simply compares their Ids and only works if the branched issue Id is higher than the triggered:

Add compare condition

If the action is to link the issues, the link would always be created from the first/older (lower Id) issue to the later/newer issue (high Id).

It's also important to implement some check(s) to prevent the same issues being matched in a following rule execution, if you want to avoid such scenario.

Updated on May 31, 2024

Still need help?

The Atlassian Community is here for you.