Automation for Jira - Writing a rule that clones stories (and their sub-tasks) linked to an Epic when the Epic is cloned

Still need help?

The Atlassian Community is here for you.

Ask the community

Platform notice: Server and Data Center only. This article only applies to Atlassian products on the Server and Data Center platforms.

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 limitation. For example, this action does not have the option to clone the stories linked to an Epic issue.

This limitation is tracked in the feature request JIRAAUTOSERVER-741 - Getting issue details... STATUS

The purpose of this knowledge article is to provide an example of 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.

Environment

  • Jira Server / Data Center 8.0.0 and any higher version
  • Automation for Jira 7.4.0 and any higher version

Solution

The solution consist 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:

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

Screenshot showing the full rule

Configuration of Automation Rule 2

(warning) 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:

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}}

Screenshot showing the full rule

Seeing the rule in action

Let's assume that we have an Epic issue linked to 2 stories, and each stories has a few sub-tasks, as shown in the screenshots below:

  • Epic Issue
  • Story 1 and its sub-tasks
  • Story 2 and its sub-tasks


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

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



Last modified on Jan 4, 2024

Was this helpful?

Yes
No
Provide feedback about this article
Powered by Confluence and Scroll Viewport.