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

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.




3 answers

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.

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.

I am using Jira 6.4.12 server instance

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)

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

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

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.

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

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)

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

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted Oct 09, 2018 in Jira Core

How to manage many similar workflows?

I have multiple projects that use variations of the same base workflow. The variations depend on the requirements of the project or issue type. The variations mostly come in the form of new statuses ...

222 views 6 0
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you