How To Bulk Clone Issues In Jira

Do you find yourself regularly copying individual issues in Jira? If so, this article will be a valuable resource! In this post, we will guide you through the process of bulk cloning issues in Jira. This helpful feature enables you to duplicate multiple issues at once, greatly saving time and effort.

Please note that Jira’s native functionality doesn’t support bulk cloning. To achieve this, you’ll need to use a Jira plugin such as ScriptRunner or Jira Misc Workflow Extensions (JMWE). In this guide, we will focus on utilizing ScriptRunner.

Getting Started

The first step is to install the ScriptRunner plugin in your Jira instance. After successful installation, locate and click on the “Script Console” under the ScriptRunner sections. This is where you’ll be running the script to clone your issues.

Preparing the Script

Here’s a simplified example of a ScriptRunner script that clones issues:

    import com.atlassian.jira.component.ComponentAccessor

    def issueManager = ComponentAccessor.issueManager
    def issueFactory = ComponentAccessor.issueFactory
    def issue = issueManager.getIssueByCurrentKey("TEST-123")

    def cloneIssue = issueFactory.cloneIssue(issue)
    cloneIssue.setSummary("Cloned issue of ${issue.key}")

    issueManager.createIssueObject(cloneIssue.reporter, cloneIssue)
    

In the script above, replace “TEST-123” with the key of the issue you want to clone. This will only clone one issue at a time. To clone multiple issues, we need to modify it a bit.

Bulk Cloning Issues

To clone multiple issues, we should first gather all the issues we want to clone into an issue list. You can do this by using a JQL query. Here’s how you modify the script:

    import com.atlassian.jira.component.ComponentAccessor

    def issueManager = ComponentAccessor.issueManager
    def issueFactory = ComponentAccessor.issueFactory
    def searchService = ComponentAccessor.getComponent(com.atlassian.jira.bc.issue.search.SearchService)
    def user = ComponentAccessor.jiraAuthenticationContext.loggedInUser
    def queryString = "project = TEST and issuetype = Bug" // replace with your JQL query
    def parseResult = searchService.parseQuery(user, queryString)
    def results = searchService.search(user, parseResult.query, com.atlassian.jira.web.bean.PagerFilter.getUnlimitedFilter())

    results.issues.each { issue ->
        def cloneIssue = issueFactory.cloneIssue(issue)
        cloneIssue.setSummary("Cloned issue of ${issue.key}")
        issueManager.createIssueObject(user, cloneIssue)
    }
    

Replace “project = TEST and issuetype = Bug” with your JQL query that matches the issues you want to clone.

Takeaways

And there you have it! Now, you have a script that clones multiple issues in Jira. Just remember that while this method is efficient, it requires careful handling. Always double-check your JQL queries and test your scripts to avoid unnecessary complications.