It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Bulk Clone Pro: How to clone entire Epic (with Issues and their Sub-Tasks)?

Fred Lunau Aug 17, 2017

Hi - I'm evaluating Bulk Clone Professional, and need to clone our "template" Epic.  This Epic contains a handful of Tasks ("Issues in Epic").  Each of these Tasks in the Epic have a bunch of Sub-Tasks.  How do I clone this entire structure? When I clone this "template" Epic using Bulk Clone Professional, I only specify this single Epic as needing to be cloned, because I want to end up with a cloned Epic that contains the same (cloned) Tasks as the source Epic contains, and have each of these (cloned) Tasks point to (cloned) Sub-Tasks.

So in the pic attached, the 5 "Issues in Epic" would also be cloned, and listed in the cloned Epic's "Issues in Epic" section.  Also, I need each of the Sub-Tasks (of each Task) to also be cloned.  So a full Epic clone.



4 answers

1 accepted

2 votes
Answer accepted
Fred Lunau Aug 18, 2017 • edited

Ok, I figured it out.  Instead of assuming that just cloning the "top level" Epic, I need to use JQL (project = MIG and "Epic Link" = MIG-84 or issuekey  = MIG-84)  - where MIG-84 is the Epic - and clone the Epic and all of the "Issues in Epic" together.  Very cool plug-in.  

Kristina McInerny Nov 14, 2017

Where do you place the JQL?  The Backlog area is the only place you can multi-select (I think) and if I do a JQL search, I am taken to a Search results page where I cannot multi-select.

Matt Sorgenfrei Nov 14, 2017 • edited

Hi Kristina - this is Fred, posting by mistake from my manager's account (oops ;_0 )  ... so I go to my project, and click on "view all issues and filters" in the upper right.  Make sure the "Advanced" link is clicked, and create a filter that selects the epic you want to clone - along with all of the tasks in that epic.  So for me, it's:

project = MIG AND "Epic Link" = MIG-84 OR issuekey = MIG-84 ORDER BY issuetype ASC, issuekey ASC

Then I save that filter.  When you're ready to clone that epic (with its tasks and task sub-tasks), run that filter (by going to your project, clicking on "view all issues and filters", and clicking on the filter you just saved).  

You'll now see the epics and tasks in that epic.  You won't see sub-tasks but they're cloned automatically with each task.  Now just follow the add-on instructions (go to tools -> bulk tools, change all X issues, and in bulk operations select all of them, click next, then select the add-on "clone issues", and you're off and running).


Fred Lunau Nov 14, 2017

Logged in as myself (Fred) now - let me know if you have any other questions on this!

Kristina McInerny Nov 14, 2017

I was able to create JQL and see the list I wanted.  I don't see tools > bulk tools etc.  I'm trying to follow which recommends going to Backlog...I don't want that.

Couldn't see how to save the filter except to save it to a local file.

Fred Lunau Nov 14, 2017

When you build up the filter (using either 'basic' or 'advanced'), there is a "Save As" button that you can click to save that filter.

We chose Bulk Clone Pro because we could clone Epics and their hierarchies across many different JIRA Projects.

Kristina McInerny Nov 15, 2017

Thanks for all of your help.  Our needs were simpler; may need this in the future though...

Kristina McInerny Nov 05, 2018

@Fred Lunau FYI - we ended up going with Jira Automation with a trigger on Epic creation to create all of the issues "below" the Epic.  It had more flexibility to create if/then scenarios for our agency model with multiple products plus the ability to suffix or prefix the issue names. I needed a coder to assist with the setup though.

Found out that we couldn't use the Epic cloning tool anymore because it would trigger Jira Automation.  Oops.  I'm sure there's a checkbox for that somewhere.

2 votes
Jonas M Aug 03, 2018


I needed the same some time ago. I got a solution with 2 scriptrunner REST Endpoints called sequentially. The first is called from a custom web item (Script Fragments) in the more-menu of an issue. It shows a dialog where you can set the summary/epic name of the new epic. After clicking submit, the second endpoint is called.

Here are the scripts for the two REST Endpoints:


import groovy.transform.BaseScript
import com.atlassian.jira.component.ComponentAccessor

@BaseScript CustomEndpointDelegate delegate

showDialog() { MultivaluedMap queryParams ->
//get issueKey from parameters of REST Endpoint call
def issueKey = queryParams.getFirst("issueKey") as String
String BASE_URL = ComponentAccessor.getApplicationProperties().getString(APKeys.JIRA_BASEURL);

//definition of Dialog with some Java Script
def dialog =
//On dialog the user can insert the summary/epic name of the new epic
//After clicking submit button, spinner is displayed and second REST Endpoint is called with new summary value
var newSum = AJS.\$("#text-input").val()
var spinning = false;

spinning = true;

var request = new XMLHttpRequest();"GET","${BASE_URL}/rest/scriptrunner/latest/custom/cloneEpicWithIssues?issueKey=${issueKey}&newSum="+newSum);

//Keep the dialog open for 15s, then close it and reload the source epic
function loadUrl(newLocation){
window.location.href = newLocation;
//show error message if field for new summary is empty
AJS.\$("#text-input").next().append('<div class="error">Summary for new Epic is required</div>')

//Dialog definition, got from scriptrunner documentation and adapted
<section role="dialog" id="sr-dialog" class="aui-layer aui-dialog2 aui-dialog2-medium" aria-hidden="true" data-aui-remove-on-hide="true">
<header class="aui-dialog2-header">
<h2 class="aui-dialog2-header-main">Clone Epic with Issues in Epic</h2>
<a class="aui-dialog2-header-close">
<span class="aui-icon aui-icon-small aui-iconfont-close-dialog">Close</span>

<div class="aui-dialog2-content">
<p>Please insert Summary of new Epic</p>
<form class="aui">
<div class="field-group">
<label for="text-input">New Epic Name<span class="aui-icon icon-required">required</span></label>
<input class="text" type="text" id="text-input" name="text-input" title="summary">
<div class="description">Please insert Name of new Epic</div>

<footer class="aui-dialog2-footer">
<div class="aui-dialog2-footer-actions">
<button id="dialog-submit-button" class="aui-button aui-button-primary">Submit</button>
<span style="padding-left: 15px; padding-bottom: 10px; display: inline-block;" class="button-spinner"></span>
<button id="dialog-close-button" class="aui-button aui-button-link">Cancel</button>

//Show dialog

Clone Epic:

import groovy.json.JsonOutput
import groovy.transform.BaseScript
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.issue.ModifiedValue
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.sal.api.user.UserManager
import javax.servlet.http.HttpServletRequest
import org.apache.log4j.Category
import com.atlassian.crowd.embedded.api.User
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.issue.IssueManager
import com.atlassian.jira.event.type.EventDispatchOption
import com.atlassian.jira.user.util.UserUtil
import com.onresolve.scriptrunner.runner.util.UserMessageUtil
import java.sql.Timestamp;
import org.apache.log4j.Logger;

@BaseScript CustomEndpointDelegate delegate

cloneEpicWithIssues(httpMethod: "GET") { MultivaluedMap queryParams,body, HttpServletRequest request ->

// Variable definition
def issueKey = queryParams.getFirst("issueKey") as String // issuekey from request parameters
def newSummary = queryParams.getFirst("newSum") as String // newSummary value from request parameters
def epic_link_field="customfield_12739";
def epic_name_field="customfield_12738";
def issueMgr = ComponentAccessor.getIssueManager()
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def linkMgr = ComponentAccessor.getIssueLinkManager()
def issueFactory = ComponentAccessor.getIssueFactory()
Issue issue = issueMgr.getIssueObject(issueKey)
def user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
Timestamp Ts = new Timestamp(System.currentTimeMillis());
CustomField epicLink = customFieldManager.getCustomFieldObject(epic_link_field);
CustomField epicName = customFieldManager.getCustomFieldObject(epic_name_field);

//Get current issues in epic -> links from and to source epic
List<IssueLink> outwardLinks = linkMgr.getOutwardLinks(issue.getId())
List<IssueLink> inwardLinks = linkMgr.getInwardLinks(issue.getId())
List<Issue> outwardLinkedIssues = [] as List<Issue>;
List<Issue> inwardLinkedIssues = [] as List<Issue>;



//sorting of epic links - not neccessary, was requirement from users
outwardLinkedIssues.sort{a,b -> a.getId()<=>b.getId()}
outwardLinkedIssues = outwardLinkedIssues.reverse()

inwardLinkedIssues.sort{a,b -> a.getId()<=>b.getId()}
inwardLinkedIssues = inwardLinkedIssues.reverse();

ModifiedValue mVal;

MutableIssue clonedIssue;
MutableIssue clonedEpic;

try {
//Clone epic with all fields
def toClone = issueFactory.cloneIssueWithAllFields(issue)
clonedEpic = issueMgr.createIssueObject(issue.reporter, toClone) as MutableIssue

//set current system time as created date, otherwise it would have created date from source epic
// is deprecated but issueManager.updateIssue didn't work, don't know why

//Set new summary and epic name (same in this case)

mVal = new ModifiedValue(clonedEpic.getCustomFieldValue(epicName), newSummary);
epicName.updateValue(null, clonedEpic, mVal, new DefaultIssueChangeHolder());

//if source epic has outward links, clone each linked issue and set epic link to new epic
//For sub-tasks, this is unfortunately not working. Therefore they are excluded
clonedIssue = issueMgr.createIssueObject(issue.reporter, toClone) as MutableIssue


mVal = new ModifiedValue(clonedIssue.getCustomFieldValue(epicLink), clonedEpic);
epicLink.updateValue(null, clonedIssue, mVal, new DefaultIssueChangeHolder());

clonedIssue = issueMgr.createIssueObject(issue.reporter, toClone) as MutableIssue


mVal = new ModifiedValue(clonedIssue.getCustomFieldValue(epicLink), clonedEpic);
epicLink.updateValue(null, clonedIssue, mVal, new DefaultIssueChangeHolder());
return Response.serverError().entity([error: e.message]).build();

String BASE_URL = ComponentAccessor.getApplicationProperties().getString(APKeys.JIRA_BASEURL);

//show success message and load new epic - doesn't work in some cases, don't know why
String clonedMessage = """
Navigating to created issue <a href="${BASE_URL}/browse/${clonedEpic.getKey()}">${clonedEpic.getKey()}</a>...
function loadUrl(newLocation){
window.location.href = newLocation;

 Maybe not the best solution, but it is working for us. At least useful as a workaround until Atlassian maybe is providing such a function in the standard JIRA application in the future.

Rajeswari Thangavel Jan 24, 2019


Can you please share the Custom Web Item configuration?

Rajeswari Thangavel Jan 25, 2019


Getting below error while executing this code. Could you please help me in fixing this?

2019-01-25 10:36:38,866 ERROR [common.UserCustomScriptEndpoint]: *************************************************************************************
2019-01-25 10:36:38,873 ERROR [common.UserCustomScriptEndpoint]: Script endpoint failed on method: GET cloneEpicWithIssues
java.lang.NullPointerException: Cannot invoke method getId() on null object
 at Script5$_run_closure1.doCall(Script5.groovy:48)
Jonas M Jan 31, 2019


here is a screenshot of the web item configuration.

I think you get the error message as you didn't provide the issue. In the configuration you do that in the "Link" field.



Rajeswari Thangavel Jan 31, 2019

Hello Jonas,

Thanks for your reply.

I configured in the same way. But the issue is not created. Could you please help me with this? Is this something related to condition?


Jonas M Jan 31, 2019


do you have a REST Endpoint configured that is called "showDialog"? It is called in the URL with the issue as parameter. It is defined in the first code snippet above. This dialog calls the second Endpoint if you click on "Submit" so it is necessary for this to work that both Endpoint exist.

Rajeswari Thangavel Feb 01, 2019

Yes and No error though. When I click on Submit it is redirected to the same source issue and when I search for new epic, unable to find.RE.PNG

Jonas M Feb 05, 2019

So, the log files don't show anything?

Then you maybe can add a logger to log some information on the issue creation or the new issue.

1 vote
Radhika Suresh Nov 04, 2018 • edited

Folks, if you have the latest version of the JIRA CLI installed (I have Atlassian CLI 8.0.0), then this command below will clone everything listed below:

  • the EPIC,
  • the issues under the EPIC,
  • the sub-tasks under the EPIC,
  • the sub-tasks under the issues under the EPIC,
  • as well as any other linked JIRA tasks 

jira --action cloneIssues --jql "project=ABC and 'Epic Link' = ABC-123 or IssueKey = ABC-123" --copySubtasks --copyLinks

Rajeswari Thangavel Jan 24, 2019


Can you please share the custom web item configurations?

0 votes
Janine Franken Jun 07, 2018

Hi Fred

But is the EPIC-Link also changed?

JQL: key = TEST-1756 OR "EPIC Link"= TEST-1756 ORDER BY issuetype ASC

The issues in the list are from different projects.

Then I do the Clone and select all the issues.

I select the following issues in the 3rd step:

  • Clone Subtasks
  • Clone Issue Links
  • Rebuild Issue Links
  • Rebuild Epic Link

Everything looks fine - except the Epic Link. This is still to the old Epic.

Radhika Suresh Jan 08, 2019

Yes, I noticed that that is the behavior for non-admins. When I ran it as an admin it copied the links correctly into the new EPIC. This is a serious detraction of the cloning tool, IMO.

Suggest an answer

Log in or Sign up to answer
This widget could not be displayed.
This widget could not be displayed.
Community showcase
Published in Marketplace Apps & Integrations

Join our webinar: “Asset Management: The Role of Context in ITSM” with Atlassian & Riada

  Hi Atlassian Community! This is Teresa from the Jira Service Desk team. On June 19th, I’ll be hosting a webinar “Asset Management: The Role of Context in ITSM” with Atlassian Partne...

179 views 2 3
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you