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)
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.
Looks like you're missing the dependency. I added the same code into a ScriptedField and it worked fine for me
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.