Extra steps required to remove Watchers that are added in a JIRA Post function Script

Wayne Cranford November 9, 2018

 When using a Post-Function Script to add Watchers we are experiencing the following:

  1. Users with Manage Watchers permissions can no longer simply remove any of those Watchers added as part of the Post Function: They must:
    (a)  delete the user
    (b)  re-add the user, and
    (c)  delete the user again within the same "Manage Watchers" 

  2. Users can only remove themselves by:
    (a)  select "Stop Watching",
    (b)  select "Start Watching", and then
    (c)  select "Stop Watching" again. 

If the screen is refreshed between either of the above (a) and (b) steps that name is automatically added back as a Watcher.

 

I did read of other reports about issues with Watchers and Plugins, so not sure it matters, but using the following script:

 

import com.atlassian.jira.component.ComponentAccessor

def watcherManager = ComponentAccessor.getWatcherManager()
def userManager = ComponentAccessor.getUserManager()

def watchUsers = {usernames ->;
usernames.each {
def user = userManager.getUserByKey(it.toString())
watcherManager.startWatching(user, issue)
}
}

def users = ["user1","user2"]
watchUsers(users)

 

Environment Adaptavist ScriptRunner v5.3.5 with JIRA v 7.4.4

1 answer

0 votes
Cyril Egan August 12, 2019

I'm seeing this behaviour in Jira 7.13.1 also.  My script just adds the assignee as a watcher in a post function.

import com.atlassian.jira.component.ComponentAccessor

def watcherManager = ComponentAccessor.getWatcherManager()

watcherManager.startWatching(issue.assignee, issue)

To stop watching the issue on the UI the user has to:

(a) select "Stop Watching",
(b) select "Start Watching", and then
(c) select "Stop Watching" again.

If they refresh the issue after step (a) then they will be still shown as the watcher.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events