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.

 

Cheers,

Ashley

3 answers

1 vote

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
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Bridget Sauer
Published Thursday in Marketplace Apps

Calling all developers––You're invited to Atlas Camp 2018

 Atlas Camp   is our developer event which will take place in Barcelona, Spain  from the 6th -7th of   September . This is a great opportunity to meet other developers and get n...

88 views 0 5
Read article

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