Shared Action

A post-function that runs a Shared action (a sequence of one or more post-functions), created on the Shared extensions page, against the current issue (or issues related to the current issue).

This post-function together with Shared extensions enables you to reuse the most frequently used configurations quickly without having to configure the same scenario multiple times. Any change made to a shared extension is instantly applied to all the workflow transitions where it is used.

To add the 'Shared action' post-function to a transition:

  1. Click Edit for the workflow that has the transition to which the post-function should be added.

  2. In the Workflow Designer:

    1. If viewing the workflow as Text, click the name of the transition and click the Post Functions tab.

    2. If viewing as a Diagram, select the transition and click Post-functions in the properties panel.

  3. Click Add post function.

  4. Select Shared action from the list of post-functions and click Add. The Shared Action Post Function screen (pictured, below) will open.

  5. Add the configuration details as specified in the Configuration details section, below.

  6. Click Add to add the post-function to the transition.

  7. Publish the workflow.

You are viewing the documentation for Jira Data Center/Server.

On This Page

Configuration details

Add the following details to configure the post-function to fit your scenario:

Shared action

Select the shared actions to be run. The list of shared actions displayed here is defined in Shared extensions.

Target issues

  • Which issues: Select the issue(s) on which the selected shared action is run. Select one of the following:

    • Current Issue: Select this option to perform the post-function on the current issue. This is the default option.

    • Sub-tasks of the current issue: Select this option to perform the post-function on the sub-tasks of the current issue.

    • Parent issue of the current sub-task: Select this option to perform the post-function on the parent of the current issue.

    • Issues that belong to the current Epic: Select this option to perform the post-function on the issues that belong to the current Epic.

    • Epic of the current issue: Select this option to perform the post-function on the Epic of the current issue.

    • Child issues of the current issue in the Portfolio hierarchy: Select this option to perform the post-function on the child issues of the current issue in the Portfolio hierarchy.

    • Parent issue of the current issue in the Portfolio hierarchy: Select this option to perform the post-function on the parent issues of the current issue in the Portfolio hierarchy.

    • Issues linked to the current issue through any link type: Select this option to perform the post-function on all issues linked to the current issue no matter the link type.

    • Issues linked to the current issue through the following link type: Select this option to perform the post-function on the issues linked to the current issue through a specific link type. Select the specific link type under Issue link, which will appear when this option is chosen.

    • Issues returned by the following Groovy script: Input a Groovy script that returns either:

      • a single Issue object

      • a Collection of Issue objects

      • a String representing the key of an issue

      • a Collection of Strings each representing an issue key.

        For example:

        • "TEST-1"

        • ["TEST-1","TEST-2"]

        • ComponentAccessor.issueManager.getIssueObject("TEST-1")

        • [ComponentAccessor.issueManager.getIssueObject("TEST-1"),ComponentAccessor.issueManager.getIssueObject("TEST-2")]

        • issue.parentObject

        • issue.getLinkedIssues()

          For more information, refer to Groovy editor in JMWE and Groovy script tester in JMWE.

    • Issues returned by the following JQL search: Input a JQL search expression, including an optional Groovy Template markup. For example:

      • project = TEST returns issues of the project with the key TEST

      • project = ${issue.get("project").key} and assignee = ${currentUser.name} returns issues of the project the current issue belongs to and assigned to the current user.

      • To operate on issues of a project with key TEST and issue type name same as the value in a text field

        <% if (issue.get("Single line text")) { %> project = TEST and issuetype = ${issue.get("Single line text")} <% } else { %> issuekey=INVALID-1 <% } %>
  • The <% if %> block is necessary to avoid an invalid JQL query when the Single-line text field is empty. In that case, the template returns a valid JQL query that returns no issue (issuekey=INVALID-1). This is in general applicable to JQL operating on select type fields with pre-determined values like Affects Version/s, Checkboxes, etc.

  • The maximum number of issues returned by a valid JQL is limited to 1000.

Conditional execution

  • Only if the condition is true: Select this option to run the post-function only when the entered expression is true.

Error Handling

  • Make transition fail when an error occurs in this post-function: Select this option to make the transition fail when an error occurs while running the post-function. An error message is displayed to the user showing the transition failure.

Example

Scenario: You want to create a testing task every time a development task with Priority set to ‘Major’ is transitioned to the stage Closed, and then assign the new issue to a testing team member.

Perform the following:

Step 1. Create a new Shared extension.

  1. Click the Administration button in the upper right corner and select Manage apps.

  2. Under JIRA MISC WORKFLOW EXTENSIONS click Shared extensions.

  3. Click the Actions tab.

  4. Click Add shared action to the right of the tabs.

  5. Add the following:

    • Action name: Enter a meaningful name for the action.

    • Description: Enter a more detailed explanation of what the action would accomplish.

    • Post-functions: To add post-functions:

      1. Click Add action.

      2. Select Create / Clone issue(s) from the list of post-functions and click Add.

      3. Configure this post-function for the appropriate Project and Issue type.
        Since you want to create a testing task for a development task with Priority set to Major, select the Only if the condition is true option and add return (issue.get("priority").getName() == "Major") to the Condition field.

      4. Click Add to add the post-function to the action.

      5. Repeat Steps i through iv using:

        1. the Assign to role member post-function in step ii, and

        2. assigning a Project Role to the intended project role member (Testing role member in this scenario) in step iii.

      6. All of these post-functions will be run in sequence.

  6. Click Save and the newly created action is added to the Shared actions list.

Step 2. Add the Shared Action post-function to the workflow transition.

  1. Click Edit for the workflow that has the transition to which the shared action should be added.

  2. In the Workflow Designer:

    1. If viewing the workflow as Text, click the name of the transition and click the Post-functions tab.

    2. If viewing as a diagram, select the transition and click Post-functions in the properties panel.

  3. Click Add post function.

  4. Select Shared Action from the list of post-functions. The Shared Action Post Function window will open.

  5. Select the newly created shared action you created in Step 1.

  6. Click Add to add the post-function to the transition.

  7. Publish the workflow.

Figure 1 - Shared Action post-function