Script no longer working after update

yadeniji January 10, 2020

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.

1 answer

1 accepted

1 vote
Answer accepted
Hana Kučerová
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
January 11, 2020

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())
}

 

yadeniji January 14, 2020

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)
Hana Kučerová
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
January 15, 2020

Hi @yadeniji ,

which version of Jira do you have now (i. e. after mentioned upgrade)?

yadeniji January 16, 2020

We are running version 8.5.1 right now

yadeniji January 22, 2020

Looks the errors stopped!

Suggest an answer

Log in or Sign up to answer