Seeking Solution for Creating Single Subtask from Multiple GitLab Commit Triggers

Edoardo
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
July 26, 2023

Hello Jira Community,

I've implemented a Jira automation involving GitLab commit comments, however, I'm encountering an issue when dealing with multiple triggers from different issues.

Here's the scenario:

  1. Issues XXX-4 and XXX-5 are linked to issue XXX-1 which is named "Released Component ABC".
  2. A commit from GitLab adds a comment to issue XXX-4: "commit 12345 XXX-4 Component ABC".

The workflow I've created is as follows:

  • If "Component ABC" is present in the comment added to XXX-4, loop over the issues linked to XXX-4.
  • If the name of the linked issue to XXX-4 is "Released Component ABC" (XXX-1), then create a subtask XXX-6 in XXX-1, rename it "Release note Commit 12345" (value 12345 is extracted with regex and saved in a smart variable), and link it to XXX-4.

This automation works fine, but I'm facing a problem. The commit comment can refer to multiple issue IDs. For instance, if the comment is "commit 12345 XXX-4 XXX-5 Component ABC", the automation is triggered twice, creating two subtasks (XXX-6 and XXX-7), each linked to XXX-4 and XXX-5 respectively, and both named "Release note Commit 12345".

Instead, I want to create only one subtask XXX-8 named "Release note Commit 12345" and link it to both XXX-4 and XXX-5.

Can anyone provide guidance on how to modify the automation to achieve this desired outcome? 

Thank you in advance for your help!

The actual workflow:

Screenshot 2023-07-26 205825.png

1 answer

0 votes
Boldizsár Vermes
Contributor
July 31, 2023

@Edoardo, welcome to the Community.

My solution would be something like this:

  • Create a variable before the branching part. This is needed to use the variable outside the branches too, so the value almost doesn't matter (I use {{#replace(" ","")}} {{/}} to have an empty initial value.)
  • In the For: Linked issues branch, before creating a subtask, use Lookup issues action and search for something like this: parent = {{issue.key}} AND summary ~ "Release note Commit 12345"
  • Add the result into the previously created variable: {{lookupIssues.first.key}}
  • Add a condition to before creating the subtask: {{variableName.isEmpty()}}
    If this is true, create a new subtask. If not, continue outside the branch.
  • After the branching part, add a new condition: {{variableName.isEmpty()}}
    If this is false, link the trigger issue to the one that the variable gives to you.

There can be different scenarios to have the same result but I think this one is maintainable enough by not being built up from two branches with the same conditions at the beginning.

Let us know if this answer helps you or you need more assistance to reach your goal.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events