Any way to automatically add all assignees for an issue as watchers

ashleyg December 9, 2015

I am just looking for a way to ensure that whoever is or was assignee for an issue should automatically get added as watcher to that issue (even if he/she hasn't commented).

I was just going through script runner functionality and i think we could achieve it using script runner listener, but i am not an expert in listeners, so i would seek your help here.

There is also a functionality there which helps to add any current user as watcher but i don't need that as that will be mess up our watchers list.

Any help/suggestions here will be greatly appreciated as always.

 

Cheers,

Ashley

3 answers

1 vote
JamieA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 10, 2015

You could use the following as a listener on the Assigned event:

import com.atlassian.jira.component.ComponentAccessor

def watcherManager = ComponentAccessor.getWatcherManager()
watcherManager.startWatching(issue.assignee, event.issue)

untested, and that's for 7.0. In 6.x you may need to convert the user from one type to another, or use issue.assigneeUser or something.

ashleyg December 10, 2015

Thanks Jamie for the prompt response :) I just copied this and pasted inside the Script runner->Script Listeners->Custom Listener and configured it for Issue Assigned Event for a project. But the issues in that project are not at all impacted by this listener. I am a novice in Listeners so i don't know what exactly should be the code. Any help here would be greatly appreciated.

ashleyg December 10, 2015

I am using Jira 6.4.12 server instance

ashleyg December 10, 2015

I just made changes with respect to issue.assigneeUser instead of issue.assignee and it works for issue assigned event. But i also need this to work when users are assigned issues via workflow transition post functions, so i also added Generic Event to the listener(since my workflow transitions fire Generic Event) and that too works fine. Can we do the same for Reporter, so what should be the modified code:- import com.atlassian.jira.component.ComponentAccessor def watcherManager = ComponentAccessor.getWatcherManager() watcherManager.startWatching(issue.assigneeUser, event.issue) watcherManager.startWatching(issue.reporterUser, event.issue)

Thanos Batagiannis [Adaptavist]
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 11, 2015

good guess ashley watcherManager.startWatching(issue.reporterUser, event.issue) will do the trick for the reporter

JamieA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 11, 2015

You need to be a bit careful that the assignee is not null, so I would surround it with: if (issue.assigneeUser) { ... }

0 votes
GabrielleJ
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 10, 2015

What is the need for automatically adding them as Watchers? Is it for Notifications? Alternatively, you can just add "Assignee" in the Notification scheme.

ashleyg December 10, 2015

Thats not the solution because jira only sends notifications to current assignee not to any other assignee of the past (if he has not commented and is in someway not a watcher)

GabrielleJ
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 14, 2015

There is a global/personal configuration to Autowatch issues you were assigned to.

0 votes
ashleyg December 10, 2015

Or else if you can help me write appropriate condition in the script runner ->script listeners under Adds the user performing the action as a watcher, if condition applies... then that should be ok with me. But then this should ensure that any user who was assignee to that issue at some point of time should be the watcher to the issue.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events