Getting an error with our script after upgrading Jira (see script below-error is here **)
import com.atlassian.jira.component.pico.ComponentManager
import com.atlassian.jira.security.roles.ProjectRole
import com.atlassian.jira.security.roles.ProjectRoleActors
import com.atlassian.jira.security.roles.ProjectRoleManager
ComponentManager componentManager = ComponentManager.getInstance()
**ProjectRoleManager projectRoleManager = ComponentManager.getComponentInstanceOfType(ProjectRoleManager.class) as ProjectRoleManager**
def String user
def project = issue.getProjectObject()
ProjectRole role1 = projectRoleManager.getProjectRole("HR")
ProjectRoleActors actors = projectRoleManager.getProjectRoleActors(role1, project)
user = actors.getUsers().toList()?.first()?.name
if(user){
issue.setAssigneeId(user)
}
I changed the ComponentManager but can't see to figure out the rest.
Hi @yadeniji ,
please try to replace your code with this:
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.security.roles.ProjectRoleManager
final String roleName = "HR"
ProjectRoleManager projectRoleManager = ComponentAccessor.getComponent(ProjectRoleManager)
def projectRole = projectRoleManager.getProjectRole(roleName)
def users = projectRoleManager.getProjectRoleActors(projectRole, issue.projectObject).applicationUsers
if (users) {
issue.setAssignee(users.first())
}
Thank you for your reply. I replaced the code, but now we get this error when I look at the post function.
The following log information was produced by this execution. Use statements like:log.info("...") to record logging information.
2020-01-14 15:09:44,961 ERROR [workflow.AbstractScriptWorkflowFunction]: ************************************************************************************* 2020-01-14 15:09:44,962 ERROR [workflow.AbstractScriptWorkflowFunction]: Script function failed on issue: COSTAT-14080, actionId: 1, file: null groovy.lang.MissingMethodException: No signature of method: static com.atlassian.jira.component.pico.ComponentManager.getComponentInstanceOfType() is applicable for argument types: (java.lang.Class) values: [interface com.atlassian.jira.security.roles.ProjectRoleManager] Possible solutions: getComponentInstanceOfType(java.lang.Class), getOSGiComponentInstanceOfType(java.lang.Class) at Script35.run(Script35.groovy:7)
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.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.