Automation for Jira - Writing a rule that clones stories (and their sub-tasks) linked to an Epic when the Epic is cloned
Platform Notice: Data Center Only - This article only applies to Atlassian products on the Data Center platform.
Note that this KB was created for the Data Center version of the product. Data Center KBs for non-Data-Center-specific features may also work for Server versions of the product, however they have not been tested. Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.
*Except Fisheye and Crucible
Summary
The Clone Issues action that comes with Automation For Jira has some limitations. For example, this action does not allow you to clone the stories linked to an Epic issue.
This limitation is tracked in the feature request JIRAAUTOSERVER-741 ( Add the ability to clone sub-tasks and linked issues when cloning a Jira issue )
This knowledge article provides an example of an automation rule that will automatically clone all the stories to an Epic along with their sub-tasks when the Epic is cloned from the UI.
Solution
The solution consists in configuring 2 automation rules, along with some preliminary steps.
Preliminary step
This step consists in creating a new type of issue link, that will be used by the 2 automation rules:
Log in as a Jira Admin user
Go to ⚙ > Issues > Issue Linking
Create a new type of link, using the parameters below:
Name: Cloners (via rule)
Outward Link Description: clones (via rule)
Inward Link Description: in cloned (via rule) by
After the link is created, it should appear as illustrated in the screenshot below:
Configuration of Automation Rule 1
New Trigger: Issue Linked
Link Types: Cloners
New Condition: Issue fields condition
First Value: Issue Type
Condition: Equals
Second Value: Epic
Branch Rule / related issues
Type of related issues: JQL
JQL:
|
Rule restricted to projects: <Your project name here>
In the Branch:
New Action: Clone Issue
Project: Same project
Issue Type: Same issue Type
Summary:
|
Choose fields to set: Epic Link > Trigger Issue
New Action: Link Issues
This issue: "is cloned (via rule) by"
Issue: "Most recently created issue"
Back on the main branch:
New Action: Edit Issue
Choose fields to set: Epic Name > (click the "..." and select) "Copy from with the following parameters":
Issue to copy value from: Current Issue
Field to copy value from: Summary
The screenshot shows the full rule
Configuration of Automation Rule 2
For this rule, make sure to tick the option Allow rule trigger in the Rule Details page, in order to allow the 1st rule to trigger this 2nd rule, as illustrated below:
New Trigger: Issue Linked
Link Types: Cloners (via rule)
New Condition: Issue fields condition
First Value: Issue Type
Condition: Equals
Second Value: Story
Branch Rule / related issues
Type of related issues: JQL
JQL:
|
Rule restricted to projects: <Your project name here>
In the Branch:
New Action: Clone Issue
Project: Same project
Issue Type: Sub-task
Parent issue: "Trigger Issue"
Summary:
|
The screenshot shows the full rule
Seeing the rule in action
Let's assume that we have an Epic issue linked to 2 stories, and each story has a few sub-tasks, as shown in the screenshots below:
Epic Issue
Story 1 and its sub-tasks
Story 2 and its sub-tasks
Let's clone this Epic, by going to More > Clone:
After the Epic is cloned:
make sure to refresh the page. You will see that the new Epic was created with 2 cloned stories linked to it:
if you click on each cloned story, you will see that they were created with the cloned sub-tasks as well:
cloned Story 1
cloned Story 2
Was this helpful?