Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

How to Execute Branches in Parallel and Maintain Order?

Mariano Tallarico _Appricity_ November 18, 2024

 

Hello community, greetings to everyone.

I wanted to share a case I’ve been working on and ask if anyone has successfully resolved something similar.

We were requested to implement an enhancement to a previous setup, where the technical challenge was to process an array obtained from a JQL query in a specific order. The solution had to adhere to the premise of minimizing the number of automation executions, avoiding the use of webhooks or unnecessary loops.

We tested two main approaches:

  1. Creating a branch with an ordered JQL query.
  2. Using a "For Each" loop to iterate over the array obtained from Lookup Issues.

Both alternatives encountered the same key issue: Jira Automation branches execute in parallel, resulting in random orders instead of maintaining the original sequence. Here are the details and results for each approach:


Alternative 1: Branch with JQL

  • Trigger: Manual (for testing purposes).
  • Branch: Executes a JQL query that returns issues in alphabetical order (e.g., ABC-1, ABC-2, ABC-3).
  • Action: Log the keys ({{issue.key}}).

Result:
Even though the JQL query returns an ordered array, the branch executes in parallel, resulting in random orders such as:

  • ABC-3, ABC-1, ABC-2
  • ABC-2, ABC-3, ABC-1
  • ABC-1, ABC-3, ABC-2

Alternative 2: For Each with Lookup Issues

  • Trigger: Manual (for testing purposes).
  • Lookup Issues: Retrieves issues in alphabetical order (e.g., ABC-1, ABC-2, ABC-3).
  • Branch: "For Each" loop over the keys ({{lookupIssues.key}}), with a logging action.

Result:
Similar to the previous case, the branch executes in parallel, resulting in random orders such as:

  • ABC-3, ABC-1, ABC-2
  • ABC-2, ABC-3, ABC-1
  • ABC-1, ABC-3, ABC-2

Conclusion:
We confirmed that Jira Automation branches execute in parallel, which makes it challenging to achieve the required serial order for this case.


Question for the community:
Do you know of any way to make a branch execute sequentially in Jira Automation? Or have you discovered creative solutions or alternatives to address similar needs?

 

Greetings, Mariano

1 comment

Bill Sheboy
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.
November 18, 2024

Hi @Mariano Tallarico _Appricity_ 

First thing, as you are asking a question I recommend posting it that way rather than as a discussion topic.  It is more likely to get community visibility and suggestions that way.

 

There is an old suggestion to allow better control (or disabling) of the parallel / asynchronously processing for automation rule branches which could be on more than one thing: https://jira.atlassian.com/browse/AUTO-32

That one finally appears to be in progress, although it is unclear what Atlassian will implement for this need.  Adding the ability to process branches sequentially may lead to many more rules exceeding some of the service limits...halting rule execution for an entire site for 12 hours up until the remainder of the entire month!

 

Given the criteria you have listed, there is no possible solution with the built-in automation rules at this time:

The solution had to adhere to the premise of minimizing the number of automation executions, avoiding the use of webhooks or unnecessary loops.

As you note, built-in rule solution approaches include:

  • Using one rule to start a loop process, which triggers a recursive, Incoming Webhook triggered rule to process the items one at a time
  • Assuming a rule triggered on a specific field change, create a recursive rule which uses the Lookup Issues action with JQL containing an ORDER BY clause, grabs the first matching issue to perform actions on it, flags it somehow as "updated for the rule", and finally makes another update to trigger recursion

Both such approaches are likely to encounter service limits for looping and / or processing time.

 

Two non-rule-based approaches are:

  • build a service outside of Jira to perform the sequential processing, using the Jira REST API endpoints, and then call that service from the rule using the Send Web Request action
  • you do not describe the problem you are trying to solve with this rule, and perhaps there is a marketplace app which can already achieve that; thus checking the marketplace could help

 

Kind regards,
Bill

Comment

Log in or Sign up to comment
TAGS
AUG Leaders

Atlassian Community Events