Groovy Script not working after JIRA 7.1.9 Upgrade

hello

after i updated JIRA to version 7.1.9 the following groovy scipt does not work anymore:

 

import com.atlassian.jira.ComponentManager
import com.atlassian.jira.issue.comments.CommentManager
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.user.*;
ComponentManager compManager = ComponentManager.getInstance()
ApplicationUser currentUser = ComponentAccessor.getJiraAuthenticationContext().getUser();
CustomFieldManager customFieldManager = compManager.getCustomFieldManager()
//Zusammenbau vom String für den Kommentar
sourceFieldVal = ""+issue.getCustomFieldValue(compManager.getCustomFieldManager().getCustomFieldObject("customfield_10900")).displayName
sourceFieldVal = sourceFieldVal[1..-2]
sourceFieldVal = "Hallo *" + sourceFieldVal + "* \
\n\ndie Hardware steht für dich zum Abverkauf bereit.\
\n\nBitte gib uns in diesem Ticket durch *Kauf bestätigen* Bescheid, ob du die Hardware kaufen möchtest.\
\nAlle relevanten Informationen zur Hardware kannst du oben im Ticket einsehen und sind ebenfalls im Kaufvertrag enthalten.\
\nDer Kaufbetrag wird vom Gehalt abgezogen.\
\n\nNach deiner Bestätigung, wird HR-Confidential den Kaufvertrag im Ticket hinterlegen. Bitte diesen Kaufvertrag ausdrucken, unterschreiben\
\nund bei Technical Services vorbeibringen.\
\nAlternativ kannst du den unterschriebenen Kaufvertrag einscannen und im Ticket hinterlegen.\
\n\nGrü▒~_e\
\nTechnical Services"
CommentManager commentMgr = compManager.getCommentManager()
commentMgr = (CommentManager) compManager.getComponentInstanceOfType(CommentManager.class)
//Der wirkliche Kommentar
commentMgr.create(issue, currentUser, sourceFieldVal, true)

the error:

2016-07-29 14:50:18,421 http-nio-9001-exec-15 ERROR ad 890x2926x1 ycr5o5 172.16.177.197,10.0.0.63 /secure/CommentAssignIssue.jspa [c.o.s.jira.workflow.ScriptWorkflowFunction] Script function failed on issue: TS-7754, actionId: 21, file: /data/home/jira/groovyscripts/TS-HardwareSale-AbverkaufFreigeben.groovy

groovy.lang.MissingMethodException: No signature of method: com.atlassian.jira.ComponentManager.getCustomFieldManager() is applicable for argument types: () values: []

        at TS-HardwareSale-AbverkaufFreigeben.run(TS-HardwareSale-AbverkaufFreigeben.groovy:9)

 best regards

toni

 

2 answers

Hi Antonio,

Moving from JIRA 6 to JIRA 7 and after getting the latest compatible SR version you will also need to update your scripts. There is a UpgradingToJira7 section in the documentation that will help you. For example in your script you need

def currentUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def commentManager = ComponentAccessor.getCommentManager()

regards

Thanos

 

still the sam error:

2016-07-29 15:24:33,093 http-nio-9001-exec-20 ERROR ad 924x3061x1 s2gc8b 172.16.177.197,10.0.0.63 /secure/CommentAssignIssue.jspa [c.o.s.jira.workflow.ScriptWorkflowFunction] Script function failed on issue: TS-7756, actionId: 21, file: /data/home/jira/groovyscripts/TS-HardwareSale-AbverkaufFreigeben.groovy
groovy.lang.MissingMethodException: No signature of method: com.atlassian.jira.ComponentManager.getCustomFieldManager() is applicable for argument types: () values: []
 at TS-HardwareSale-AbverkaufFreigeben.run(TS-HardwareSale-AbverkaufFreigeben.groovy:9)

Antonio according to your logs you still use ComponentManager, please read the link to the docs above....

1 vote
Joe Pitt Community Champion Jul 29, 2016

This is the often overlooked cost when going outside the base product.

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Posted 4 hours ago in Confluence

Calling all marketing teams who use Confluence - we want to hear from you!

Hi Community! me again 🙂 If you’re a marketing team using Confluence, we want to hear your story! How did you start using Confluence? What are your use cases? What have been some of the benefits?...

29 views 1 2
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you