Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Class not found in Adaptavist Scriptrunner Script for TM4J

Jira Version: 7.13.0

Scriptrunner for Jira Version: 5.5.3

Test Management for Jira Version: 6.4.0-jira7

Hi,

I copied this example script from here:

package examples.docs.tm4j

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
import com.kanoah.testmanager.service.publicservice.IssueLinkPublicService
import com.onresolve.scriptrunner.runner.customisers.WithPlugin

//Must use @WithPlugin annotation to pick up Test Management for JIRA classes
@WithPlugin("com.kanoah.test-manager")

def numberOfTests = 0
def numberOfPassingTests = 0

def issueLinkPublicService = ComponentAccessor.getOSGiComponentInstanceOfType(IssueLinkPublicService)

def countTestsInIssue = { Issue targetIssue ->
issueLinkPublicService.getTestCases(targetIssue.key, "lastTestResultStatus").each {
numberOfTests++
if (it.get("lastTestResultStatus") == "Pass") {
numberOfPassingTests++
}
}
}

if (issue.issueType.name == "Epic") {
ComponentAccessor.getIssueLinkManager().getOutwardLinks(issue.id).each {
if (it.issueLinkType.name == "Epic-Story Link") {
countTestsInIssue(it.destinationObject)
}
}
} else {
countTestsInIssue(issue)
}

if (numberOfTests == 0) {
return 100
}
return (double)(numberOfPassingTests * 100) / numberOfTests

and put it in an Automation for Jira rule.

When the rule gets executed, I get the following exception in atlassian-jira.log:

automation-rule-executor:thread-1 ERROR admin [c.o.scriptrunner.automation.ExecuteScriptIssueAction] *************************************************************************************
2019-06-25 10:09:28,889 automation-rule-executor:thread-1 ERROR admin [c.o.scriptrunner.automation.ExecuteScriptIssueAction] Script function failed on Automation for Jira rule: Sync Test cases status, file: <inline script>
java.lang.NoClassDefFoundError: com/kanoah/testmanager/service/publicservice/IssueLinkPublicService
at examples.docs.tm4j.Script359.run(Script359.groovy:14)
at org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.eval(GroovyScriptEngineImpl.java:321)
at org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.eval(GroovyScriptEngineImpl.java:159)
at javax.script.AbstractScriptEngine.eval(AbstractScriptEngine.java:233)
at javax.script.ScriptEngine$eval.call(Unknown Source)
at com.onresolve.scriptrunner.runner.ScriptRunnerImpl.runScriptAndGetContext(ScriptRunnerImpl.groovy:176)
at com.onresolve.scriptrunner.runner.ScriptRunner$runScriptAndGetContext$4.callCurrent(Unknown Source)
at com.onresolve.scriptrunner.runner.ScriptRunnerImpl.runStringAsScript(ScriptRunnerImpl.groovy:165)
at com.onresolve.scriptrunner.runner.ScriptRunner$runStringAsScript$3.call(Unknown Source)
at com.onresolve.scriptrunner.canned.jira.utils.CustomScriptDelegate.doScript(CustomScriptDelegate.groovy:70)
at com.onresolve.scriptrunner.canned.jira.utils.CustomScriptDelegate$doScript$6.call(Unknown Source)
at com.onresolve.scriptrunner.automation.ExecuteScriptIssueAction.executeScript(ExecuteScriptIssueAction.groovy:132)

 

 

2 answers

Looks like you're missing the dependency. I added  the same code into a ScriptedField and it worked fine for me

Hi Arthur,

quite late my answer, but did you try to remove the 1st line of code? (package examples.docs.tm4j)

This made the post-function example work for me. 

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Marketplace Apps & Integrations

5 mobile apps for Jira Cloud to boost productivity

  It’s very important to have access to the workflow process from anywhere. Especially if you manage the work of others. There is no difference whether you’re out of office, or drive a ca...

209 views 2 5
Read article

Community Events

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

Find an event

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

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you