Assigning bugs to testers

In our JIRA environment, only testers may create or re-open bugs.
In order to improve our workflow, we’d like that the bug will be assigned to the relevant tester as soon as it is resolved.
The easy solution is to use the ‘assign to reporter’ post-function, but it does not work well for bugs which were re-opened and re-fixed, because we want to assign it to the tester who re-opened the bug.

So, I added a ‘Reopened By’ user-picker custom field which is set automatically to the current user when re-opening a bug. Then I came up with three approaches to implement this automatic assignment mechanism:

1. Add a ‘re-fix’ transition
2. Add a hidden ‘last tester’ field
3. Implement a Groovy script

Here are the details of each solution:

1. Add a ‘re-fix’ transition

With this approach, I duplicate the ‘resolve issue’ transition to a new one called ‘re-fix issue’ or something similar. Then, set the following:
‘resolve issue’ – add condition: ‘Reopened By’ is empty ; add post function: assign to reporter
‘re-fix issue’ – add condition: ‘Reopened By’  is not empty; add post function: set ‘assignee’ field to ‘Reopened By’

2. Add a hidden ‘last tester’ field

With this approach, I create a custom user field called ‘Last Tester’. The field is not available on any screen, and is updated by post functions as follows:
‘create issue’ – set ‘Last Tester’ to current user
‘reopen issue’ – set ‘Last Tester’ to current user
Then add a post-function to the ‘Resolve Issue’ action to set ‘assignee’ to ‘Last Tester’

3. Implement a Groovy script

With this approach, I use the following groovy script (after a lot of trial-and-error) as a post-function of the ‘Resolve Issue’ transition (scripted post function is available as part of the free Script Runner plug-in). Note that it was tested on JIRA 6 which includes a big change in the various ‘User’ objects, so I’m not sure it would work on earlier versions.

import com.atlassian.jira.ComponentManager
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.user.ApplicationUser
import com.atlassian.crowd.embedded.api.User
CustomFieldManager customFieldManager = ComponentManager.getInstance().getCustomFieldManager()
CustomField reopenedBy = customFieldManager.getCustomFieldObject("customfield_10300")
User reporter = issue.getReporter()
ApplicationUser reopenedByUser = (ApplicationUser) issue.getCustomFieldValue(reopenedBy)
if (reopenedByUser == null) {
} else {
 User reopener = reopenedByUser.getDirectoryUser()

Eventually I opted for option #3 since it was the cleanest (no excess transitions or fields to add and maintain).

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s