HI,
Using the below script to add an user to watcher list using Script runner in the issue Create PostFunction
import com.atlassian.jira.ComponentManager ComponentManager componentManager = ComponentManager.getInstance() def watcherManager = componentManager.getWatcherManager() def userManager = componentManager.getUserUtil() def watchUsers = {usernames -> usernames.each { def user=userManager.getUser(it) watcherManager.startWatching(user,issue.getGenericValue()) } } def users = ["X"] watchUsers(users)
However, I find the below errors in my log file
at java.lang.Thread.run(Thread.java:662) Caused by: javax.script.ScriptException: groovy.lang.MissingPropertyException: No such property: watcherManager for class: com.atlassian.crowd.embedded.ofbiz.OfBizUser at org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.eval(GroovyScriptEngineImpl.java:318) at org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.eval(GroovyScriptEngineImpl.java:111) ... 185 more
ANother clue is that this script works on the Script Console , but in the post script function it fails
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Looks like this thread is thread. This is urgent and needs some help
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Updated version for JIRA 7.1.4:
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)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
->
In Jira Server 7.3.0 shows a problem with that symbol '-'
Can you tell me what changed? I want the same code to work for the new version of jira SD.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
We upgraded to server 7.5 and chose not to use the addition of the user to the watchers list. I found another way solving my case. Thanks a lot.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Had to add this to make it work, but atlast it is working as expected
package com.onresolve.jira.groovy.canned.workflow.postfunctions
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.