Reopen issue when new Bug is linked
Goal | Automatically reopen a closed issue when a new issue - of a specific type - is linked to it. |
---|---|
Scenario | When a new Bug is created for an existing feature, you want to automatically reopen the issue for that feature. The new Bug is linked to the existing issue, and you want JMWE to reopen the issue. Additionally, you want to add a comment indicating why the issue was reopened and copy fields from the original issue to the new Bug. |
Components | Transition issue(s) post function, Copy issue fields post function |
Baseline |
|
Note: the steps below require your workflow to have two specific status values:
Closed (for example, work that is complete but is pre-release or support tickets that have a window for customers to reopen)
Reopened (or something similar)
Figure 1, below, shows these status values at the end of the workflow: Closed is used for work that is complete but is not fully Done, and Reopened with an incoming transition from Closed and and outgoing transition to In Progress. Your transitions do not need to match, but you will need either:
A status that represents issues that are complete, but are not Done
andA status that represents reopening an issue after it has been completed or
A transition from Closed to Backlog or
Your Backlog status configured to enable Allow all statuses to transition to this one.
Requirements
JIRA Administrator login
You are viewing the documentation for Jira Cloud.
1. Add the Transition issue(s) post function
Log in to your Jira instance as an Administrator.
In the upper right corner of the window, click Settings ( ) and select Issues.
In the left-hand sidebar, click Workflows.
From the list of Workflows, click Actions ( ) for the appropriate workflow and select Edit.
Switch to Diagram view if you are not already using it.
Select the Create transition (Point 1, Figure 1, right).
Click the Post Functions link (Point 2, Figure 1, right).
Click Add post function at the top of the list of existing post functions.
Select Transition issue(s) from the list of post functions and click Add at the bottom of the list.
3. Configure the post function
Note: Leave all fields to their default values unless specified below!
For Target issues, select Issues linked to the current issue through the following link type (Point 1, Figure 2, right).
For Issue link, select relates to (Point 2, Figure 2, right).
Click the Transition Picker button to select a Transition (Point 3, Figure 2, right).
In the Pick a transition window:
Select your workflow from the Workflow name pulldown menu.
Select the transition between Done and Reopened (e.g. Issue Reopened).
Click Use transition ID.
Click Advanced options and then click Transition screen.
Check the box for Add Comment (Point 4, Figure 2, right).
For the Comment field, enter the following script (Point 5, Figure 2, right):
This issue has been reopened due to: Bug {{ issue.fields.issuekey }} ({{ issue.fields.summary }}).
Click Settings.
Check the box for Run this post-function only if a condition is verified (Point 6, Figure 2, right).
In the Write a script editor, enter the following script (Point 7, Figure 2, right):
{{ issue.fields.issuetype.name == "Bug" }}
Click Add (Point 8, Figure 2, right).
4. Add the Copy issue fields post function
Lastly, we need to add the Copy issue fields post function to the Create transition; this post function can run at any point during the Create transition because there are no dependencies between this post function and the Transition issue(s) post function from Step 3. The Copy issue fields post function will copy three field values from the feature issue to the Bug:
Fix version from the feature issue will be copied to Affects versions on the Bug
Assignee and Watchers from the feature issue will be copied to Watchers on the Bug, ensuring that notifications on the new Bug will be sent appropriately
Back in your Workflow Editor, verify that you are still working on the Create transition.
Select the Post Functions tab and click Add post function.
Select Copy issue fields from the list of post functions and click Add at the bottom of the list.
For Source issue(s), select Issues linked to the current issue through the following link type (Point 1, Figure 3, right).
For Issue link, select relates to (Point 2, Figure 3, right).
Under Fields to copy, click Add (Point 3, Figure 3, right) and use the values in the table below.
Field | From | Additional options |
---|---|---|
Affects versions | Fix versions |
|
Watchers | Assignee |
|
Watchers | Watchers |
|
Repeat Step 6 for each field listed. Your configuration of Fields to copy should match Figure 3, right.
Click Advanced options > Settings.
Check the box for Run this post-function only if a condition is verified (Point 4, Figure 3, right).
Enter the following script in Write a script (Point 5, Figure 3, right):
{{ issue.fields.issuetype.name == "Bug" }}
Check the box for Allow Jira to send notifications for this change (Point 6, Figure 3, right).
Click Add (Point 7, Figure 3, right).
Save and Test the Workflow
Save your Workflow and publish the changes. To test that the post function is configured correctly, create a new Bug and link it to any issue that is closed. Verify that the closed issue is moved to the appropriate status and that the field values from the closed issue have been copied to the Bug.