Jira — Clone an epic with all children

Ethan O'Brien
5 min readAug 31

--

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.

Create manual trigger
Save a new manual trigger

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.

Click to add a conditional

The conditional type is JQL condition.

Choose JQL condition

Add the query issuetype = Epic

Add the query to check for Epic

Add an action to execute

Next, we will add an action to execute if the conditional is true

Click THEN: Add an action

Select the Clone issue action to first clone the epic

Search for Clone issue

I chose not to update any of these fields by default. You can set many of the newly cloned issue fields if desired.

Save the new clone action

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

Search for define variable action

Set the variable name to your choice with a smart value of {{createdIssue}}. This will store the cloned epic link in the variable {{epicLink}}.

Set the variable to be the epic link

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.

Click FOR EACH: branching

The branch rule will be for related issues

Click Branch rule / 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.

Loop stories within the epic

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.

Add issue fields condition

Verify that the issue is not an issue of epic

Verify that it is not an 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.

Remove clone from the summary prefix

On the cloned issue, we need to set the epic link

Add setting of epic link on the cloned issues

Use the smart variable {{epicLink}} which we defined in an earlier step

Set the epic link to the smart variable

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.

Run the automation

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.

Open the audit log

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.

Details for an audit message

--

--

Ethan O'Brien

Software engineering started as a career and now it's my passion. Helping the world through code is one of the most rewarding things. First time blogger!