Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

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
titleClone an Epic and its Stories
Info

Create a sequence

  1. Add the "Sequence of post-functions" post-function to the "Clone now" transition.

  2. Click on "Add post function" 

  3. Clone Epic: Add the Create issue

  4. In the sequence add the "Create issue" post-function.

    1. Select the destination project from in "Project"

    2. Select the "Issue type as " Epic"Select the link type as "is cloned byCalculated"

    3. Using the "Set fields of the new section"

      1. Select the "Epic Name" field

      2. Select the "Copy value from current issue" option

    4. Save the post-function.

  5. Clone Stories: Add a "Transition Linked Issues" post-function configured as

    1. Input the transition name as "Clone Stories" (will be created later)

    2. Select the Link type as "is cloned by"

    3. Save the post-function.

  6. Click on "Add"

  7. Publish the workflow

Create "Clone Stories" transition

  1. 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.

  2. 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

  1. Select the Project as "Same as current issue"

  2. Select the "Issue Type" as "Story"

  3. Input the Summary as:

    Code Block
    {{it.fields.summary}}
  4. Select the "Epic Link" field under "Set fields of new issue"

    1. Select "Set field value to" option

    2. Input the following template

      Code Block
      {{issue.key}}
  5. Select "Create Multiple Issues" checkbox under "Multiple issue creation"

  6. 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).

  7. Select "Iterator returns JSON" option

  8. Click on "Add"

  9. 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.

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

Panel
titleClone an Epic and its Stories

Create a sequence

  1. Add the Sequence of post-functions post-function to the "Clone now" transition.

  2. Click on "Add post function" 

  3. Clone Parent: Add the Create issue post-function.

    1. Select the destination project from Project

    2. Select the Issue type as "Calculated"

    3. Input the template {{ issue.fields.issuetype.name }}

    4. Select the link type as "is cloned by"

    5. Save the post-function.

  4. Clone Subtasks: Add a "Transition Linked Issues" post-function configured as

    1. Input the transition name as "Clone Subtasks" (will be created later)

    2. Select the Link type as "is cloned by"and input

      Code Block
      {{ issue.fields.issuetype.name }}
    3. Select the "Link to new issue" as "clones"

    4. Configure the fields

    5. Click on Save

  5. Add another "Create issue" post-function to clone the linked issues

    1. Select the destination project in "Project"

    2. Select the "Issue type" as "Calculated" and input

      Code Block
      {{ it.fields.issuetype.name }}
    3. Select "Multiple issue creation" option and input the following template:

      Code Block
      languagejs
      {{ issue | linkedIssues("blocks",['key']) | length }}
    4. Select “Linked Issues” under “Set fields of new issue”

      1. Select “Set field value to Groovy expression”

      2. Input the following code:

        Code Block
        [
        {
          "type": {"name":"Blocks"},
          "inwardIssue": {"key":"{{transition.context.newIssueKey}}"}
        }
        ]
    5. Save the post-function.

  6. Click on "AddSave"

  7. Publish the workflow

Create
  1. .

Now when you trigger the transition "Clone Subtasks" transition

  1. 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.

  2. 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

    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

    1. Add the "Sequence of post-functions" post-function to the transition

    2. In the sequence add the "Create issue" post-function.

      1. Select the destination project in "Project"

      2. Select the "Issue type" as "Calculated" and input

        Code Block
        {{ issue.fields.issuetype.name }}
      3. Select the "Link to new issue" as "clones"

      4. Configure the fields

      5. Click on Save

    3. Add another "Create issue" post-function to clone the sub-tasks

      1. Select the destination project in "Project"

      2. Select the "Issue type" as "Subtask"

      3. Under the "Parent issue" input the following template:

        Code Block
        languagejs
        {{ transition.context.newIssueKey }}
      4. Select "Multiple issue creation" option and input the following template:

        Code Block
        languagejs
        {{ issue | subtasks | 
      dump(2)Select "Iterator returns JSON" option
      1. length }}

      (note that "clones" here is the name of the reverse direction of the "is cloned by" link type used above).

      1. Save the post-function.

    4. Click on "AddSave"

    5. Publish the workflow.

    Now when you trigger the transition "Clone now" the Parent and its subtasks are cloned to the new project.

    ...