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:

Issue link type - cloners

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:

"Epic Link" = {{destinationIssue}}

  • Rule restricted to projects: <Your project name here>

In the Branch:

New Action: Clone Issue

  • Project: Same project

  • Issue Type: Same issue Type

  • Summary:

{{issue.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

Automation rule to clone stories from cloned EPIC

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:

checkbox to Allow other rule to trigger this rule

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:

parent = {{destinationIssue}}

  • 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:

{{issue.summary}}

The screenshot shows the full rule

Clone sub-tasks from stories using Automation

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

    Screenshot of epic issue

  • Story 1 and its sub-tasks

    Screenshot of story and its sub-tasks

  • Story 2 and its sub-tasks

    Screenshot of story  2 and its sub-tasks

Let's clone this Epic, by going to More > Clone:

Clone epic using "Clone" option

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:

    Epic cloned with its two child stories

  • 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 epic child story 1 with its own sub-tasks

    • cloned Story 2

      Cloned epic child story 2 with its own sub-tasks

Updated on June 7, 2024

Still need help?

The Atlassian Community is here for you.