How to create and link multiple issues to the parent using Run Command Line Interface (CLI)

This article explains how to create multiple issues and link the created issues to the parent issue in a post function using Run Command Line Interface (CLI).

Instructions

  1. Log in to Jira as an administrator.
  2. Click Projects from the top navigation bar and select the desired project. If the required project is not visible from the drop-down, click View All Projects and select the project from the list.
  3. Click Project Settings at the left bottom of the project page.

  4. Navigate to the Workflows section and click the icon adjacent to the relevant workflow.

  5. Select the desired transition to add a post function. For this example, the post function is added to the Done transition.

  6. Go to the Post Functions section and click Add post function.

  7. Select the CLI Action option and click Add.

  8. Add two post functions here with the same CLI action.
    1. The first post function uses the createIssue action to create the issues, and;
    2. The second post function uses the runFromIssueList and linkIssue actions to add the links.
  9. Provide the following CLI action in the Action section:

    --action run --server %base_url% --user "automation" --password "xxx"
  10. Provide the following CLI action in the Data field section:

    --action createIssue --project "PEN" --summary "testissue1" --type "Bug" --labels "add"
    --action createIssue --project "PEN" --summary "testissue2" --type "task" --labels "add"
  11. Add another post function as in step 7.

  12. Provide the following CLI action in the Action field section:

    --action run --server %base_url% --user "automation" --password "xxx"
  13. Provide the following CLI action in the Data field section:

    --action runFromIssueList --jql "project = 'PEN' AND labels = 'add'" --common "--action linkIssue --issue %original_key% --toIssue @issue@ --link blocks "

    The complete post function looks as shown:

  14. Click Add in the post function.

  15. Click Publish to publish the workflow changes.

When a Jira issue transitions from Done, the created issue gets updated with the issue links.

For this example, as two issues are created in this transition, the issue on which the transition is performed is linked with the two newly created issues as shown in the screenshot:


We recommend testing this in a testing environment before deploying in the production environment.