Jira — Clone an epic with all children
--
If you’ve ever been a scrum master or managed a sprint team, one of the goals is to keep the team and stories as organized as possible. On my current team, when we create a new epic, we have a set of stories that will always be in the epic. Those stories include how we will A/B test, Splunk dashboards, technical discussion pages, test plans, etc. In Jira, there is no easy way to clone an epic with all the linked issues, until we leverage automation!
Create a new automation
To create a new automation within Jira, open an existing issue, and on the top right, open the “Actions” menu, then click “Manage automations”.
Add a new manual trigger event
In our sequence, a manual trigger is the simplest way to start.
Add a conditional check for an epic
To limit the types of issues, we can trigger this automation on, add a new conditional to check for a type of Epic.
The conditional type is JQL condition.
Add the query issuetype = Epic
Add an action to execute
Next, we will add an action to execute if the conditional is true
Select the Clone issue action to first clone the epic
I chose not to update any of these fields by default. You can set many of the newly cloned issue fields if desired.
Create an action to save the newly cloned epic link
A second action to define a variable is needed to store the newly cloned epic link, which will be applied to each cloned linked issue
Set the variable name to your choice with a smart value of {{createdIssue}}. This will store the cloned epic link in the variable {{epicLink}}.
Create a new branch to loop on each linked issue
Once the epic is cloned, we will then loop through each linked issue and clone it.
The branch rule will be for related issues
For this rule, the type of related issues we want to loop through are all the Stories in the epic.
It is important to deselect the option to only include issues that have changed since the last time this rule was executed.
Add conditional to ignore the newly cloned epic
The new conditional will be a simple field condition check that the sub-issue is not an epic.
Verify that the issue is not an issue of epic
Clone the issue into the same project with an epic link
Add a new action to clone the issue. By default, the summary is prefixed by Clone. Since these are the sub-issues, no need to include the word Clone.
On the cloned issue, we need to set the epic link
Use the smart variable {{epicLink}} which we defined in an earlier step
Run the automation on your template epic
Once created, go to your epic template, open the Actions menu, and click your automation. There is no success message once the execute happens. Refresh your backlog to see the new issue and all of its children.
Debugging issues with the audit log
Once the automation has been executed, you can see what happened by opening the audit log. Go to your project settings, click Automation, and then open the script you want to debug.
View any execution of the automation event
Once the details of that run are open, you will be able to see each decision that was made and which items were created from it. If any errors occur you can see the message to fix it.