jira automation incorrectly links my tasks

julia December 4, 2024

I have a manual automation

I create an EPIC: TEST123

then run my manual automation, this then should create 3 tasks

Then: create a new: TASK "Task 1 Create your project"
For most recently created issue
    then create a new: TASK "Task 2 create your part numbers"
    and: create a new: TASK "Task 3 create your bill of materials"


This works. I now want my tasks to be linked.  

Task 1 Create your project

    Task 2 create your part numbers (LINK TO TASK 1)

    Task 3 create your bill of materials (LINK TO TASK 1)


This is where the problem occurs. Instead I get: 

 

Task 1 Create your project

    Task 2 create your part numbers (LINK TO TASK 1)

        Task 3 create your bill of materials (LINK TO TASK 2)


Even though Task 3 is still under the "For most recently created issue" it should create a link to TASK 1. I cannot get it to work


jira automation.pngtask1 creation link.pngtask2 creation link.png

1 answer

1 vote
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 5, 2024

Hi Julia,

When you link the issues to "Most recently created issue", that is relative to the last issue created.

As you are branching to the first one, Task 1, you could change the link to "Current Issue" as that will refer to the "branched to" issue.

Kind regards,
Bill

julia December 5, 2024

Thanks for the quick response!

For Task 2 I have "most recently created issue" and this correctly links me to Task 1

But I cannot figure out any setting that will link Task 3 to Task 1. I am wondering if in Task 1 I need to save its issue key to a variable, and then in Task 3 assign the link to the variable I created...but I have no idea how to do that or if that is even correct

I only have these 2 options for what my issue is linking to:

Screenshot 2024-12-05 100326.png

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 5, 2024

Thanks for that information; I am using Jira Cloud rather than Data Center and see something differently for that action.

Let's try this: 

  • in that field, type in {{issue.key}} rather than using the dropdown list
  • when that expression appears below the field, select it for use
  • test your rule to see if it links correctly
julia December 5, 2024

thank you again for the details. ok tried the {{issue.key}} but now TASK 3 has no linked issues

 

issue_key assignment.png

EPIC:
epic.png

TASK1 (with correct link to TASK 2):

task1.png
TASK 2 (correctly shows backward link to TASK 1):
task2.png


TASK 3 (INCORRECTLY HAS NO LINKS):

task3.png

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 5, 2024

That is curious...it states right there under the field in the action that smart values work, as does the documentation: 

https://confluence.atlassian.com/automation/jira-automation-actions-993924834.html#Jiraautomationactions-linkissuesLinkissues

 

Please add a write to the audit log inside the branch with the following to check what the value is, then re-test to see if the issue is present:

branched to issue key: {{issue.key}} and first created issue: {{createdIssues.get(0).key}}

 

julia December 5, 2024

definitely weird!
i must have some syntax messed up somewhere

AUTOMATION:
automation.png

AUDIT LOG:audit log.png

EPIC:
epic.png


TASK1:
task1.png


TASK2: 
task2.png

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 5, 2024

Please remove that text from the "more options...additional fields" fields area and instead add a Log Action to write that text to the audit log:

https://confluence.atlassian.com/automation/jira-automation-actions-993924834.html#Jiraautomationactions-logactionLogaction

julia December 9, 2024

opps sorry! here is the log action. LOG ACTION.pngAUDIT LOG WITH NEW MESSAGE.png

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 9, 2024

Thanks!  That indicates either value should have worked for the linking.

Let's try this: remove the branch and directly link to that first created issue:

  • ...
  • action: create issue (This is your 1st one)
  • action: re-fetch issue (This is to slow the rule down a bit before the link attempts)
  • action: create issue (This is your 2nd one)
    • add a link to {{createdIssues.get(0).key}}
  • action: create issue (This is your 3rd one)
    • add a link to {{createdIssues.get(0).key}}
  • ...

 

If that does not work, there are two other methods to try, with JSON and one-by-one branching.

julia December 9, 2024

note that for issues 2 and 3, I also have components: copy from issues: copy from parent. will this setup with no branch affect this? create issue component copy from issue.png

julia December 9, 2024

Good day! Thank you very much for the help. The linked issue piece is working! Some additional questions:
1. Does this mean that I need to remove all branching?

2. I have a list of about 15 tasks that my complete automation runs, does this mean I need to keep track of the index for each one that I want to link to and adjust the {{createdIssues.get(X).key}} where is the index of the task I want to link to.

3. Do I need to refetch issues?

Also, this did break the component inheritance. 

WHAT I NEED:

  • EPIC COMPONENT: PCB EPIC
  •     TASK 1 COMPONENTS: BLAH1, BLAH2
    • TASK 2 COMPONENTS: BLAH1, BLAH2
    • TASK 3 COMPONENTS: BLAH1, BLAH2

 

WHAT I GET:

  • EPIC COMPONENT: PCB EPIC
  •     TASK 1 COMPONENTS: BLAH1, BLAH2
    • TASK 2 COMPONENTS: BLANK
    • TASK 3 COMPONENTS: BLANK
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 9, 2024

1. Does this mean that I need to remove all branching?

Answer: Correct, the branching is no longer needed. It only helped with the linking and that now works.

 

2. I have a list of about 15 tasks that my complete automation runs, does this mean I need to keep track of the index for each one that I want to link to and adjust the {{createdIssues.get(X).key}} where X is the index of the task I want to link to.

3. Do I need to refetch issues?

Answer: Yes, and this will get complicated / brittle very quickly for that many tasks.  Additionally, you may need to add additional re-fetch actions to slow the rule down to make the linking successful. 

 

Answer regarding the Component field copying...are you setting the Epic Link when the issue is created AND using "Copy from Epic" for the Components?  Have you tested that approach?

If that does not work, a single branch could be used at the end to copy the Components or JSON could be attempted as each issue is created.

julia December 9, 2024

Thank you for the response. 
1. I create my epic, assign my component "PCBA EPIC"

2. I then run my automation that checks for component "PCBA EPIC"

3. at which point my automation creates a bunch of standardized tasks for a PCBA board design grouped by the linking. I was originally going to use subtasks but cannot use those in different sprints, so I adjusted that to tasks with linking

4. you mentioned that it can become brittle...is there a better way to do 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 9, 2024

So is the trigger issue an Epic?  If so that may simplify things a bit:

  • trigger: manual
  • condition: issue type equals Epic
  • condition: Component equals PBCA EPIC
  • action: create issue (1st one)
    • set the Epic Link to Trigger Issue or {{issue.key}}
    • copy the Components from Trigger Issue
  • action: re-fetch issue
  • action: create issue (2nd one)
    • set the Epic Link to Trigger Issue or {{issue.key}}
    • copy the Components from Trigger Issue
    • add the issue link to {{createdIssues.get(0).key}}
  • action: re-fetch issue
  • ... repeat for all the needed tasks, and adjusting the index for the links

 

Regarding "brittle"...In my opinion, any rule this long (i.e., around 35 steps) which relies on a person to correctly select the indices in the get() could be difficult to maintain.  There are other ways to do this, although not necessarily better, such as using multiple rules and custom fields to determine the linking.

One benefit of having everything in one rule is making it easier to see / correct problems when they happen.

julia December 10, 2024

Thank you for going through this. Yes making it easier to see/correct problems when they happen was part one of why I did one rule, also, having my team only have to run 1 rule and they get everything they need. 

Clarification to your order (below with UNDERLINE AND BOLD)

  • trigger: manual
  • condition: issue type equals Epic
  • condition: Component equals PBCA EPIC
  • action: create issue (1st one)
    • set the Epic Link to Trigger Issue or {{issue.key}}
    • automation creates 2 components: the Components equals Schematic, Review
  • action: re-fetch issue
  • action: create issue (2nd one)
    • set the Epic Link to Trigger Issue or {{issue.key}}
    • copy the Components from 1st Issue
    • add the issue link to {{createdIssues.get(0).key}}
  • action: re-fetch issue
  • ... repeat for all the needed tasks, and adjusting the index for the links
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 10, 2024

With the complexities of this rule, I recommend not trying to also copy Components from the newly created issues.  Instead add them again.

Suggest an answer

Log in or Sign up to answer