Groovy script no longer works after JIRA upgrade?

steven rothenberg March 6, 2019

Our system was upgraded to 8.0.2 and now getting this error:

Message:
Compilation error(s):
script1551890638056291169545.groovy: 4: unable to resolve class com.atlassian.jira.ComponentManager
 @ line 4, column 1.
   import com.atlassian.jira.ComponentManager

Any suggestions on how to get script working again? Here is the whole script

import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.ComponentManager
import com.atlassian.jira.issue.customfields.option.LazyLoadedOption
def issueManager = ComponentAccessor.getIssueManager()
def customFieldManager = ComponentAccessor.getCustomFieldManager()
/* */
def cField = customFieldManager.getCustomFieldObject(10600)
def cFieldValue = issue.getCustomFieldValue(cField)
String FieldName = cFieldValue
/* */
def cField1 = customFieldManager.getCustomFieldObject(10601)
def cFieldValue1 = issue.getCustomFieldValue(cField1)
String FieldName1 = cFieldValue1
/* */
def cField2 = customFieldManager.getCustomFieldObject(10603)
def cFieldValue2 = issue.getCustomFieldValue(cField2)
String FieldName2 = cFieldValue2
/*def cField1 = customFieldManager.getCustomFieldObject(Desired_Semester)
def cFieldValue1 = issue.getCustomFieldValue(cField1)*/
String FieldConcat = (FieldName + " " + FieldName1 + " " + FieldName2)
return FieldConcat;

 

4 answers

2 accepted

0 votes
Answer accepted
Jamie Echlin _ScriptRunner - The Adaptavist Group_
Atlassian Partner
March 6, 2019

We tried to distil what we think will be important to our users in our release notes too: https://scriptrunner.adaptavist.com/latest/jira/releases/UpgradingToJira8.html

0 votes
Answer accepted
Choon Keat Seet
Contributor
March 6, 2019

Its in the realase notes

https://confluence.atlassian.com/adminjira/preparing-for-jira-8-0-955171967.html

under Component Managed Moved, sorry i havent upped yet so not yet refactored so thats all i know

0 votes
Adarsh Kesharwani
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
June 1, 2020

An alternate approach is using ComponentAccessor instead, and you may see the API documentation for this class here:

https://docs.atlassian.com/software/jira/docs/api/7.11.0/com/atlassian/jira/component/ComponentAccessor.html

 

getComponent and  getComponentByType are two key methods to load components of a specific type. Sample code is below:

Old Code:

RemoteIssueLinkService remoteIssueLinkService = ComponentManager.getComponentInstanceOfType(RemoteIssueLinkService.class)

RemoteIssueLinkService.RemoteIssueLinkListResult links = remoteIssueLinkService.getRemoteIssueLinksForIssue(currentUser, issue)

New Code:

RemoteIssueLinkService.RemoteIssueLinkListResult links =  ComponentAccessor.getComponentOfType(RemoteIssueLinkService.class).getRemoteIssueLinksForIssue(currentUser, issue);

 

0 votes
steven rothenberg March 6, 2019

Thanks so much for that information.  I found what I needed - the new location for Component Manager (com.atlassian.jira.component.pico package)

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events