Hello!
I am trying to figure out how to get a groovy script calling a builtin canned script with Scriptrunner for Confluence to work.
import com.atlassian.sal.api.component.ComponentLocator
import com.atlassian.confluence.spaces.SpaceManager
import com.atlassian.user.UserManager
import com.atlassian.user.GroupManager
import com.onresolve.scriptrunner.canned.confluence.admin.AddRemoveWatchers
//Managers
def spaceManager = ComponentLocator.getComponent(SpaceManager)
def groupManager = ComponentLocator.getComponent(GroupManager)
def userManager = ComponentLocator.getComponent(UserManager)
//Canned built-in script
def removeWatchers = new AddRemoveWatchers()
//Variables
def spaceKey = "TEST"
def groupNames = "confluence-users"
def userKeys = ""
def targetSpace = spaceManager.getSpace(spaceKey)
def targetGroup = groupManager.getGroup(groupNames)
def targetUser = userManager.getUser(userKeys)
//Script Parameters
def scriptParams = [
"FIELD_CONTENT_TYPE": "Space",
"FIELD_SPACE_KEY": targetSpace,
"FIELD_GROUPS": targetGroup,
"FIELD_USERS": targetUser,
"FIELD_WATCH_OR_UNWATCH": "Unwatch",
]
//Run Script
def runScript = removeWatchers.doScript(scriptParams)
runScript
Console giving the errror:
groovy.lang.GroovyRuntimeException: Could not find matching constructor for: com.onresolve.scriptrunner.canned.confluence.admin.AddRemoveWatchers() at Script170.run(Script170.groovy:13)
And before that, a groovy.lang.MissingMethodException error for the same thing (not even sure how the error can change overnight without any changes).
The only examples I have found are for calling the CopySpace or Labels scripts.
My scriptrunner/groovy-fu is lacking, and despite having AddRemoveWatchers class opened as referenced, unsure what command/method/call is needed, and/or run the built-in script.
The goal is to automate the AddRemoveWatchers for designated spaces with a Event Listener or Job.
I appreciate any insight and help!
-Melanie