How can I import a custom plugin class into a Scriptrunner script?

Vlad Harip August 29, 2017

Hello,

I am working on a plugin that I want to use as a sort of custom library for JIRA. I want to wrap up usual operations like getting a custom field's value, setting it, migrating a issue to a new workflow, etc so i remove the thousand of lines of redundant code in our instance.

I am follwing Adaptavist's instructions about creating bundled scripts and I downloaded their bundled script plugin example.

My problem is that I can't manage to import a custom class into my Script Console. I have a custom class (currently just using the one implemented in teh Adaptavist example) that i tried adding as a component in atlassian-plugin.xml:

 

package com.onresolve.scriptrunner.canned.jira.workflow

import com.onresolve.scriptrunner.canned.CannedScript
import com.onresolve.scriptrunner.canned.util.BuiltinScriptErrors
import com.onresolve.scriptrunner.canned.util.SimpleBuiltinScriptErrors
import com.onresolve.scriptrunner.runner.customisers.ScriptListener
import groovy.util.logging.Log4j

@ScriptListener
@Log4j
class SampleScriptListener implements CannedScript {

//Canned script code
}



<component key="testScript1" name="Sample Script"
class="com.onresolve.scriptrunner.canned.jira.workflow.SampleScriptListener" public="true"
application="jira">
<interface>com.onresolve.scriptrunner.canned.CannedScript</interface>
</component>
 

 

The problem is if I try to import com.onresolve.scriptrunner.canned.jira.workflow.SampleScriptListener in a groovy script, i get an unresolved reference error for my import.

I have this question floating around but I still haven't found a solution that works for me. Has anyone managed to get this to work? If yes, could you please share how you did it? I've been trying to do this for quite some time with no success.

 

Thank you!

1 answer

0 votes
MoroSystems Support
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 29, 2017

Hello Vlad, 

I think this docs https://scriptrunner.adaptavist.com/4.3.5/jira/scripting-other-plugins.html could help you. It shows how to develop scripts using other JIRA plugins services.

Regards,

Milos

Suggest an answer

Log in or Sign up to answer