I tested using a custom class following the sample script and class included in the ScriptRunner documentation, https://scriptrunner.adaptavist.com/latest/jira/#_script_roots, 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
Files:
foo.groovy
import util.Bollo
log.debug ("Hello from the script")
Bollo.sayHello()
Bollo.groovy
package util
public class Bollo {
public static String sayHello() {
"hello sailor!!!"
}
}
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 https://jamieechlin.atlassian.net/browse/GRV-544 (especially the comments) will help you understand more.
Regards
Thanos
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.
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.