How to automatically add watchers when you have the bug watcher notification plugin installed

I am trying to automatically add watchers to certain issue types in a project on creation.  Although the bug watcher plugin allows for a filter that would do this I can't enforce that users will create these filters.  Thus I would like a script to do this at creation.

Adaptavist helped with a plugin that would do this but the plugin keeps getting in the way after about 4 different iterations.

 

I am running JIRA 7.x and this script should have worked

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue

def watcherManager = ComponentAccessor.getWatcherManager()
def userManager = ComponentAccessor.getUserManager()
def users = ["admin", "anuser"] //user keys of users you want to start watching the issue
Issue issue = issue

users.each { userKey ->
    def userToWatch = userManager.getUserByKey(userKey)
    if (userToWatch)
        watcherManager.startWatching(userToWatch, issue)
    else 
        log.warn "User with key ${userKey} is  ot a valid user"
}

 

It was erroring out probably because of some hooks the issue watcher custom field from Bug watchers notification plugin was causing.

 

Does anyone have a suggestion on how I can get around this?

 

2 answers

This widget could not be displayed.

Hi Pat!

We are using for your case two different plugins: JIRA Watcher Field and JIRA Suite Utilities. They both are free. First allows create a custom field of users type which is connected with Watchers. The second one allows automaticly update custom fields and also this field. So user is added to the watchers on creation transition in the workfow you want.

I have both of those plugins and life would probably be easy for me if it wasn't for the Bug watcher notification plugin which is making the watchers part of most scripting behave differently.  I'm certain if I wasn't using this plugin that I could get the script to work.

Thank you for your answers.

 

You want to say 'Bug watcher' impedes 'JIRA Suit' from update watchers field?

That appears to be what is happening.  NOTE:  The bug watcher program allows individuals the ability to set a filter and become a watcher when any ticket with a certain criteria is created.  If I could get my end users to do as I ask I wouldn't need to do it in the workflow with this plugin however the plugin does appear to be giving me issues when I try to program the action in a transition.

This widget could not be displayed.

You're right... the script should work. Maybe provide the errors being thrown by the Bug Watchers Notification plugin? That may suggest a workaround.

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted Tuesday in Jira

What modern development practices are at the heart of how your team delivers software?

Hey Community mates! Claire here from the Software Product Marketing team. We all know software development changes rapidly, and it's often tough to keep up. But from our research, we've found the h...

293 views 1 4
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