...
Using the Sequence of post-function post-function you can clone an issue and its linked issues too. Let's assume on the trigger of the transition "Clone now" you want to clone an Epic and its Stories to a different project.
Panel |
---|
title | Clone an Epic and its Stories |
---|
|
Info |
---|
Create a sequence Add the "Sequence of post-functions" post-function to the "Clone now" transition. Click on "Add post function" Clone Epic: Add the Create issue In the sequence add the "Create issue" post-function. Select the destination project from in "Project" Select the "Issue type as " Epic"Select the link type as "is cloned byCalculated" Using the "Set fields of the new section" Select the "Epic Name" field Select the "Copy value from current issue" option
Save the post-function.
Clone Stories: Add a "Transition Linked Issues" post-function configured as Input the transition name as "Clone Stories" (will be created later) Select the Link type as "is cloned by" Save the post-function.
Click on "Add" Publish the workflow
Create "Clone Stories" transition On the Epic workflow of the destination project (on the same workflow if both Epics share the same workflow), create a transition named "Clone Stories" on the Create transition to the same initial status. Hide that transition from users by adding a "Hide From User Condition"
Clone Stories: Add the Create issue post-function to the "Clone Stories" transition Select the Project as "Same as current issue" Select the "Issue Type" as "Story" Input the Summary as: Code Block |
---|
{{it.fields.summary}} |
Select the "Epic Link" field under "Set fields of new issue" Select "Set field value to" option Input the following template
Select "Create Multiple Issues" checkbox under "Multiple issue creation" In the iterator write the following script: Code Block |
---|
{% set from = issue | issueProperty("jmwe-created-from") | field("key") %}
{{issue | linkedIssues( "clones" ) | find({key:from}) | stories | dump(2) }} |
(note that "clones" here is the name of the reverse direction of the "is cloned by" link type used above). Select "Iterator returns JSON" option Click on "Add" Publish the workflow
Now when you trigger the transition "Clone now" the Epic and its Stories are cloned to the new project. |
Cloning an issue and its subtasks
Using the Sequence of post-function post-function you can clone an issue and its subtasks too. Let's assume on the trigger of the transition "Clone now" you want to clone a Parent and its Subtasks to a different project.
Panel |
---|
title | Clone an Epic and its Stories |
---|
|
Create a sequence Add the Sequence of post-functions post-function to the "Clone now" transition. Click on "Add post function" Clone Parent: Add the Create issue post-function. Select the destination project from Project Select the Issue type as "Calculated" Input the template {{ issue.fields.issuetype.name }} Select the link type as "is cloned by" Save the post-function.
Clone Subtasks: Add a "Transition Linked Issues" post-function configured as Input the transition name as "Clone Subtasks" (will be created later) Select the Link type as "is cloned by"and input Code Block |
---|
{{ issue.fields.issuetype.name }} |
Select the "Link to new issue" as "clones" Configure the fields Click on Save
Add another "Create issue" post-function to clone the linked issues Select the destination project in "Project" Select the "Issue type" as "Calculated" and input Code Block |
---|
{{ it.fields.issuetype.name }} |
Select "Multiple issue creation" option and input the following template: Code Block |
---|
| {{ issue | linkedIssues("blocks",['key']) | length }} |
Select “Linked Issues” under “Set fields of new issue” Select “Set field value to Groovy expression” Input the following code: Code Block |
---|
[
{
"type": {"name":"Blocks"},
"inwardIssue": {"key":"{{transition.context.newIssueKey}}"}
}
] |
Save the post-function.
Click on "AddSave" Publish the workflow Create .
Now when you trigger the transition "Clone Subtasks" transition On the parent workflow of the destination project (on the same workflow if both parent and subtask share the same workflow), create a transition named "Clone Subtasks" on the Create transition to the same initial status. Hide that transition from users by adding a "Hide From User Condition"
Clone Subtasks: Add the Create issue post-function to the "Clone Subtasks" transition Select the Project as "Same as current issue" Select the "Issue Type" as "Sub-task" Select the “Parent issue” as “Current issue” Input the Summary as: Code Block |
---|
{{it.fields.summary}} |
Select "Create Multiple Issues" checkbox under "Multiple issue creation" In the iterator write the following script: Code Block | {% set from = issue | issueProperty("jmwe-created-from") | field("key") %}
{{issue | linkedIssues( "clones" ) | find({key:from})now" the Parent and its subtasks are cloned to the new project. |
Cloning an issue and its subtasks
Using the Sequence of post-function post-function you can clone an issue and its subtasks too. Let's assume on the trigger of the transition "Clone now" you want to clone a Parent and its Subtasks to a different project.
Info |
---|
Create a sequence Add the "Sequence of post-functions" post-function to the transition In the sequence add the "Create issue" post-function. Select the destination project in "Project" Select the "Issue type" as "Calculated" and input Code Block |
---|
{{ issue.fields.issuetype.name }} |
Select the "Link to new issue" as "clones" Configure the fields Click on Save
Add another "Create issue" post-function to clone the sub-tasks Select the destination project in "Project" Select the "Issue type" as "Subtask" Under the "Parent issue" input the following template: Code Block |
---|
| {{ transition.context.newIssueKey }} |
Select "Multiple issue creation" option and input the following template: Code Block |
---|
| {{ issue | subtasks | |
dump(2)Select "Iterator returns JSON" option
(note that "clones" here is the name of the reverse direction of the "is cloned by" link type used above). Save the post-function.
Click on "AddSave" Publish the workflow.
Now when you trigger the transition "Clone now" the Parent and its subtasks are cloned to the new project. |
...