How can I create stories using Jira automation without duplicates

Rita Arellano April 15, 2024

Hi All, 

So, I found how to create stories with Jira automation, but I keep getting duplicates. So I have 'Component' field instead of 'Teams.'  I have a total of 6 'Components' that can be added to an epic at any time - and it can sometimes just be 1 Component or many. The rule I created keeps returning duplicates. This is my use case:

Anytime the 'Component' field is edited - meaning when a new 'Component' is added at an epic level - create a story for that component and prefix the summary of that story with the team's Component. 

Rule:

I created two seperate rules, because I thought it be easier, but no.... So I have a rule for Component = X and Component = Y

Please let me know how can I avoid duplicate stories and have a story created each time a Component is added to the epic - the story must have the Components prefix:

Rule X

X.jpgY.jpg

2 answers

1 accepted

1 vote
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.
April 16, 2024

Hi @Rita Arellano 

You could first check if the issues exist before creating them...

  • When using multiple rules, one for each component value, you could first check if the issue already exists (using JQL or Lookup Issues and checking the found issues), and only created it when it does not exist.
  • When using one rule, with repeated current issue branches (one for each component field values), and perform the same check for the presence of the issue before creating it.

Also, what do you want to happen if a component value is removed?

Kind regards,
Bill

0 votes
Rita Arellano April 16, 2024

@Bill Sheboy 

Is this something close? I am only focusing in the creation of the stories, if a component gets taken out the epic - that will be something I will tackle later, but first, I added the check of duplicates before the action of creating stories, but that is not yielding any stories now, any advise from here on out? 

X V2.jpgY V3.jpg

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.
April 16, 2024

To clarify a bit, what does "duplicate" mean for the scenario: 

  1. another issue exists with specific text in the Summary field
  2. something else?

 

If it is the Summary check, perhaps try this:

  • trigger: value changes for Components
  • branch: to current issue
    • condition: component contains "X"
    • related issues condition, with JQL: no issues exist with "X" in the Summary
    • action: create your issue
  • branch: to current issue
    • condition: component contains "Y"
    • related issues condition, with JQL: no issues exist with "Y" in the Summary
    • action: create your issue
  • ...repeat as needed for different components

The branches help isolate the logic for each block.

Rita Arellano April 19, 2024

I tried some variation of what you have proposed and its working a bit better, no longer getting duplicates. But I still have an issue. Please see the following scenarios below. Thank you in advance for your time. 

1. Component X is entered in Epic = Passes - story gets created correctly

2. Component X and Y entered in Epic = Passes - both stories get created correctly

3. Component Y is entered in Epic = Passes - story gets created correctly

4. Component Y is entered first then component X  in Epic = Fail, two stories for Y are created upon entering each component and X does not get created. 

How can I have it in where it does not matter which 'Component' is entered first - story gets created for each component regardless of sequence entered? Issue with Y.jpg

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.
April 19, 2024

Please note in you rule you are using two different conditions:

  • if Component / s equals (in any order)...
  • if Component / s contains any of...

I believe you want to use the contains condition for all of your tests; otherwise it will only look for an exact match to the values noted.

 

Rita Arellano April 19, 2024

Hi @Bill Sheboy 

Thank you for catching that, yes now I can enter them in any order now, but I have another issue... which ever 'Component' I enter last it automatically creates two stories for component = X and component = Y

So, its now happening like this:

1. when component X is entered in epic first: 
                1 X story is created for component = X

2. Then Y  is entered: (should only create story for component = Y)
                1 X story is created for component = X
                1 Y story is created for component = Y

and then Vice Versa:

1. when component Y is entered in epic first: 
                1 Y story is created for component = Y

2. Then X  is entered: (should only create story for component = X)
                1 X story is created for component = X
                1 Y story is created for component = Y

How can I have it so if story already exists - do not create? 

NEW ISSUES.jpg
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.
April 19, 2024

Yes, using either a related issues condition with JQL to check before creating the issue in the branch...or, using a Lookup Issues with JQL and then checking no issues were returned.

I recommend trying the related issues condition first; you will need one before each issue create action.

Like Rita Arellano likes this
Rita Arellano April 19, 2024

Thank you so much for all your help. It has taught me so much. I was able to create stories for each component - like 10 different ones flawlessly and when component gets deleted from epic screen it does not add another component - since my trigger kicks off when issue is getting edited. Hope this helps anyone else: 

RES.jpg


What fixed the duplication of issues getting created. Added this before creating the issue:
fIX.jpg

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.
April 20, 2024

Well done!

I recommend periodically checking for feature changes to automation rules.  If / when the advanced branching on smart values is added for Jira Data Center, all of your cases can be collapsed into a single loop.  Here is the backlog suggestion if you want to watch / vote for it to see progress: https://jira.atlassian.com/browse/JIRAAUTOSERVER-749

After that becomes available, your rule could change to this:

  • trigger: issue updated
  • condition: issue type is epic
  • action: create a variable named varComponentList, containing a comma-separated values list of the components to check.  For example: X,Y,Z
  • advanced branch: over the split apart list from the variable, using {{varComponentList.split(",")}} and with a loop variable named varComponent
    • condition: check if the trigger issue has the component for {{varComponent}}
    • related issues component: check with JQL if no existing Story issues have {{varComponent}}
    • action: create the issue for the new story

 

Suggest an answer

Log in or Sign up to answer