I have hobbled together a script which find users with a specific project role and then removes them from that project role. I am running into an error that I haven't been able to fix and hoping for guidance from you.
I have tried adding the user key as part of a one set collection then as a string, I have broken the script into two parts with one part retrieving the users with the designated role and the second part deleting a set of users within the same project with the designated project role with both parts working by themselves. There are only two variables whose values change - the user key and the project key.
Here is the error:
Error: groovy.lang.MissingMethodException: No signature of method: com.atlassian.jira.bc.projectroles.DefaultProjectRoleService.removeActorsFromProjectRole() is applicable for argument types: (String, com.atlassian.jira.security.roles.ProjectRoleImpl, String...) values: [JIRAUSER00000, Developers, ZEBRA, atlassian-user-role-actor, ...] Possible solutions: removeActorsFromProjectRole(java.util.Collection, com.atlassian.jira.security.roles.ProjectRole, com.atlassian.jira.project.Project, java.lang.String, com.atlassian.jira.util.ErrorCollection), removeActorsFromProjectRole(com.atlassian.jira.user.ApplicationUser, java.util.Collection, com.atlassian.jira.security.roles.ProjectRole, com.atlassian.jira.project.Project, java.lang.String, com.atlassian.jira.util.ErrorCollection) at Script7533$_run_closure1$_closure2.doCall(Script7533.groovy:61) at Script7533$_run_closure1.doCall(Script7533.groovy:53) at Script7533.run(Script7533.groovy:37)
------------------------------------------
Here is the code:
The clue is in here:
Possible solutions: removeActorsFromProjectRole(java.util.Collection, com.atlassian.jira.security.roles.ProjectRole, com.atlassian.jira.project.Project, java.lang.String, com.atlassian.jira.util.ErrorCollection)
The uNameKey must be in a collection (of size 1).
And a project object is expected rather than a project key string.
And rather than passing a null ErrorCollection, create one so you can examine the result
Try
import com.atlassian.jira.util.ErrorCollections
def errorCollection = ErrorCollections.empty()
projectRoleService.removeActorsFromProjectRole([uNameKey], projectRole, project, roleActorType, errorCollection)
if (errorCollection.hasAnyErrors()) {
log.error errorCollection.toString()
}
Thank you so much! I had realized that I needed to change uNameKey to a collection but changing project to the project object instead of the project key was the extra piece that I was missing.
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.