How do you use a custom class in a console script?

I tested using a custom class following the sample script and class included in the ScriptRunner documentation,, and it worked correctly in the Script Console specifying the script file. On the server the script file (foo.groovy) is placed in this directory, <jira-home>\scripts. The class file (Bollo.groovy) was placed in <jira-home>\scripts\util. I even tested changing the class directory (e.g. custom). This required changing the corresponding import call in the script (e.g. change 'import util.Bollo' to 'import custom.Bollo') and changing the package declaration in the class file (e.g. change 'package util' to 'package custom'). When I tested the script in the Script Console specifying the script file it worked. However, when I tried to paste the script from the file into the Script Console I get 'unable to resolve class' error when I click run. It appears that ScriptRunner console script is run so that the relative path location does not work like it does for the script file. I am trying to find some information on how to address the script root location in the ScriptRunner console script or where the class needs to be placed to be accessible to the ScriptRunner console script. It appears that the JIRA classes are stored in C:\Program Files\Atlassian\JIRA\atlassian-jira\WEB-INF\classes\com. However, adding a sub-directory to this location with the custom class does not make the class accessible. Can anyone help me to get my class working with a console script?  I am sure there is a simple solution but I cannot find it.  Thank you for any help.

System Info:

JIRA - v6.3.15

ScriptRunner - 3.1.3




import util.Bollo

log.debug ("Hello from the script")




package util

public class Bollo {

                public static String sayHello() {

                                "hello sailor!!!"



2 answers

1 accepted

2 votes
Accepted answer

Hi Will,

I am afraid is not possible to import a class that exists in a file, in a script that exists in your Script runner console. I think this link (especially the comments) will help you understand more.



What I did was create a scratch file (I called it scratch.groovy) and I simply use that for testing all my code instead of the console... and then run it as a file.   I created a simple PHP interface to edit the code, upload new code and run it via a REST call.   using this method I didn't have to worry about where I could us basescript vs. my own class.

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Feb 07, 2019 in Marketplace Apps

A Timeless Love Story

It started as any story starts, on a normal, rainy day.   Admin meets App, and her name was Klok2, and like any first relationship we were both trying to make it work but neither one knew what...

466 views 8 27
Read article

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