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

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

This widget could not be displayed.

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
Community showcase
Posted Tuesday in Jira

What modern development practices are at the heart of how your team delivers software?

Hey Community mates! Claire here from the Software Product Marketing team. We all know software development changes rapidly, and it's often tough to keep up. But from our research, we've found the h...

128 views 1 3
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