Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Simplifying a Complex Jira Automation Based on Reporter Group Membership

Nicolas Rigaill
Contributor
December 11, 2024

 

 

Hi everyone,

I have an automation that is triggered when an issue of type "Initiative" is created. Its goal is to populate a custom field "Squads contributing" based on the group the reporter belongs to.

Current Setup:

  • The automation checks sequentially if the reporter belongs to one of the 40 predefined squads.
  • If a match is found, the "Squads contributing" field is updated with the corresponding squad.
  • If no match is found, the automation moves to the next condition.
    You can see an excerpt in the attached screenshot.

2024-12-11_15h38_49.png

Challenges:

  1. High Maintenance:

    • If a squad is renamed or a new one is added, the automation needs to be updated manually.
    • This is time-consuming, especially with 40 squads currently configured.
  2. Technical Limitations:

    • Due to the 65-component limit per automation, the setup had to be split into three separate automations. This adds even more complexity.

Question:
Is there a simpler or more efficient way to handle this use case? For example:

  • A more dynamic structure to map the squads?
  • An integration or script that could automatically retrieve the reporter's group membership?

I don’t have ScriptRunner in my environment, so solutions need to rely on standard Jira automations or feasible alternatives within this scope.

Thank you in advance for your help and ideas!

1 answer

1 accepted

2 votes
Answer accepted
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.
December 11, 2024

Hi @Nicolas Rigaill 

I recommend using a Lookup Table for such mapping scenarios: https://community.atlassian.com/t5/Automation-articles/Update-Create-lookup-table-action-improvements/ba-p/2427798

With that, your rule would reduce to only a few steps rather than conditions for each group:

Maintenance is easier and isolated to updates to the lookup table.

 

What do you want to do if there is no match to the Reporter?

 

Kind regards,
Bill

 

UPDATED 2024-12-13: I replaced the steps to call the REST API to instead use the new groups smart value for the user object.

Nicolas Rigaill
Contributor
December 13, 2024

Hello Bill, 

Thank you for your response.

I’ve thoroughly read all the documentation provided, but I still can’t resolve this issue, nor do I know how to control the results from the API call.

In the meantime, Atlassian support suggested another approach: using a smart value to retrieve the list of the reporter's groups {{reporter.groups}} and then searching for the value I need within that list. I can retrieve the list, but I can’t filter it to extract only the group I’m interested in. Here’s the smart value I’m using:

 

First log action: 

{{reporter.groups}}

Second log action:

{{#if(not(reporter.groups.isEmpty))}}
{{#forEach(reporter.groups)}}
{{#if(equals("bot-group-tpm", .))}}
Found group: {{.}}
{{/if}}
{{/forEach}}
{{else}}
Not found
{{/if}}

And here’s the result:2024-12-13_14h45_01.png

Thank you,

Nicolas

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.
December 13, 2024

Thanks, I just learned something new: the user smart value now provides "groups".

 

Let's modify the approach I described earlier to use that information...

Testing indicates the groups smart value appears to be one of the dynamic smart values, which is found just-in-time when it is used.  And so to query it, the values must be saved as text first.

  • action: create variable
    • name: varReporterGroups
    • smart value: {{issue.reporter.groups}}
  • if you wanted to test for the "bot-group-tpm" group
    • smart values condition:
      • first value: {{varReporterGroups.split(", ").match("(bot-group-tpm)")}}
      • condition: equals
      • second value: bot-group-tpm

 

Assuming your Squads all have group names matching a pattern, such as "bot-group-ABCD", you could still use the lookup table approach:

  • action: create variable
    • name: varReporterGroups
    • smart value: {{issue.reporter.groups}}
  • action: create the table to map Squad groups to the data needed
    • name: varGroupToData 
      • row
        • key: bot-group-tmp
        • value: some data for the group
      • row
        • key: bot-group-ABCD
        • value: some other data
      • ...
  • action: create variable, to find the group from the reporter
    • name: varSquadGroup
    • value: {{varReporterGroups.split(", ").match("(bot-group-.++)")}}
  • action: something to use the table data with {{varGroupToData.get(varSquadGroup)}}

 

I will update my first post to handle this new method.

Nicolas Rigaill
Contributor
December 16, 2024

Hello @Bill Sheboy ,

Thank you very much !

It works perfectly with the lookup table and its way easier to maintain than my previous automation.

Thank you again!

Nicolas

 

Edit: 

Actually, I realized that the lookup table wasn't necessarily needed.
So, with the two variables, I can update my group field.
It's even better because there’s no maintenance required for this automation.

 

Step 1:

Trigger

Step 2:

Create variable:

variable: varReporterGroups

Smart value: {{isue.reporter.groups}}

Step 3:

Create variable:

variable: varSquadGroup

Smart value: {{varReporterGroups.split(", ").match("(bot-squad-,++)")}}

Step 4:

Edit issue:

My_Customfield: {{varSquadGroup}}


2024-12-16_17h17_56.png

 

 

Like Bill Sheboy likes this
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.
December 16, 2024

Awesome, and well done!

Shouldn't that comma in the expression be a period (any character token)?

{{varReporterGroups.split(", ").match("(bot-squad-.++)")}}

 

Like Nicolas Rigaill likes this
Nicolas Rigaill
Contributor
December 16, 2024

You're right, I fixed it.

Thank you!

Like Bill Sheboy likes this

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events