Our version: Jira 7.12.0
We have a Jira project that we use to manage our IT assets (servers, workstations, network gear, etc.) With most of our projects having a user auto-watch the issues they create makes sense ... it doesn't in this project. So, I am trying to write a script to un-watch the issue in a post function when the issue is created. The script runs fine ... no errors, but the issue still shows as being watched. Grrr! I also tried it as a script listener on the issue created event ... still no dice. If I stick it on another transition(other than Create) or use the issue updated event in a script listener it works just fine. I just can't seem to get it to not do it on issue created. Anybody have any thoughts on this. Below is the script ... it's pretty simple.
Post-function version
import com.atlassian.jira.component.ComponentAccessor;
import org.apache.log4j.Category
log.setLevel(org.apache.log4j.Level.DEBUG);
def watcherManager = ComponentAccessor.getWatcherManager();
def locale = new Locale("ENGLISH", "US");
//Kill all watchers ... well, not the watchers themselves.
def currentWatchers = watcherManager.getWatchers(issue, locale);
log.debug("Current watcher size: " + currentWatchers.size());
for(user in currentWatchers){
log.debug("Removing user as watcher: " + user);
watcherManager.stopWatching(user, issue);
}
//Do we still have watchers? Shouldn't.
def newCurrentWatchers = watcherManager.getWatchers(issue, locale);
log.debug("Current watcher size: " + newCurrentWatchers.size());
for(user in newCurrentWatchers){
log.debug("Grrr we still have a watcher: " + user);
}
Script listener version
import com.atlassian.jira.component.ComponentAccessor;
import org.apache.log4j.Category
log.setLevel(org.apache.log4j.Level.DEBUG);
def watcherManager = ComponentAccessor.getWatcherManager();
def locale = new Locale("ENGLISH", "US");
//Kill all watchers ... well, not the watchers themselves.
def currentWatchers = watcherManager.getWatchers(event.issue, locale);
log.debug("Current watcher size: " + currentWatchers.size());
for(user in currentWatchers){
log.debug("Removing user as watcher: " + user);
watcherManager.stopWatching(user, event.issue);
}
//Do we still have watchers? Shouldn't.
def newCurrentWatchers = watcherManager.getWatchers(event.issue, locale);
log.debug("Current watcher size: " + newCurrentWatchers.size());
for(user in newCurrentWatchers){
log.debug("Grrr, we still have a watcher: " + user);
}