Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
Community Members
Community Events
Community Groups

ScriptRunner's CLASSPATH, or how to use Groovy classes for validation

Dear all,

I am using successfully the ScriptRunner with Groovy scripts for

postconditions etc.

Now I would like to make a library of functions in groovy and put it

into a class, so that is methods are called by different script as

post functions for different transitions.

I am knowledgeable enough of Java's package/import/classpath

philosophy, but I do not know how this translates in the JIRA

standalone/Script Runner set-up.

I have the following files:


// start code snippet

package sed.jira;


import com.atlassian.jira.ComponentManager


import java.util.HashMap

import com.atlassian.jira.issue.CustomFieldManager

import com.atlassian.jira.issue.Issue

import com.atlassian.jira.issue.MutableIssue

import com.atlassian.jira.issue.comments.CommentManager


import com.atlassian.jira.event.type.EventDispatchOption



import sed.jira.JiraLibrary;


JiraLibrary jl = new JiraLibrary();


def Category log = Category.getInstance("com.onresolve.jira.groovy.PostFunction"




// end code snippet


and a simple: 


// start code snippet

package sed.jira;


class JiraLibrary { 

      String myMethod(String pippo) { 

          return pippo+ ":" + pippo;




// end code snippet

I would like TestGroovy.groovy to be called by the ScriptRunner

but it fails with:

unable to resolve class sed.jira.JiraLibrary @ line 24, column 1

I guess my question boils down to:

a) do I need somehow to compile (I do not have a groovy compiler on my

Jira box) the code and package it in a jarfile or similar?

b) what would I put the scripts or the compiled versions thereof?

What's ScriptRunner (or JIRA's ) CLASSPATH?



2 answers

1 accepted

0 votes
Answer accepted

Michele - there is information on this here: "script roots" section) - but it's only pertinent to the new beta version.

You can download it from the same page if you have a recent enough jira instance.

For the current version you need to compile a jar really, although I would recommend trying the new version as using dependent classes and libraries will be much easier.

Hi Jamie,

Running Jira 6.2.2 on Windows. Had a post-function and listener-enabled class in package com.onresolve.jira.groovy.canned.workflow.postfunctions.

Just upgraded Script Runner 2.2.x to to 3.0-b11 in order to get Behaviours function back, and now when I view ScriptRunner Listeners, I see an 'undefined' value and getting an error in atlassian-jira.log:

2014-06-20 15:28:47,401 ajp-apr-8009-exec-9 ERROR <user> 928x25038x2 6mf16d <ip> /rest/scriptrunner-jira/latest/listeners [] Could not get script name:
groovy.util.ResourceException: Malformed URL: bundle://177.0:0/, null
    at groovy.util.GroovyScriptEngine.getResourceConnection(    at groovy.util.GroovyScriptEngine.loadScriptByName(

Caused by: groovy.util.ResourceException: Malformed URL: file:/C:/Tools/Atlassian/JIRA-Data/scripts/, null

Naturally, this is referring to the newly created 'script-root' directory introduced in 3.0.

Attempting to resolve, I've just moved my old post-function script (with full path) into the new 'scripts' directory and added "-Dplugin.script.roots=C:\Tools\Atlassian\JIRA-Data\scripts" to Java Opts (but not changed classpaths yet).

But this hasn't helped. Same error.

Any ideas?

Seems adding Dplugin.script.roots was unnecessary; now that default path is included twice (if Script Console is anything to go by).

Hmm, hope I'm not going bonkers but it looks like the scriptrunner utility groovies/classes etc have moved to a new package/path; if so this might need to be noted on the 3.0 pages!?

From 2.2: com.onresolve.jira.groovy.canned.*

Now 3.0: com.onresolve.scriptrunner.canned.jira.workflow.postfunctions
com.onresolve.scriptrunner.canned.jira.utils etc?

I'll need to adjust imports and try again.

EDIT: -- Yep, that's done it. Adjusted the packages and my class now appears in the Script Listeners list again. Bril. :)

David - yes, some packages were moved, sorry about that but I didn't have much choice. I need to document that.

I will make it so that it doesn't add the path twice...

I'm not really sure why you got the malformed url exception though, looks ok.

try below exmple:

import com.atlassian.jira.event.issue.AbstractIssueEventListener

class JiraLibrary extends AbstractIssueEventListener {


void issueUpdated (IssueEvent event) {



Suggest an answer

Log in or Sign up to answer
Community showcase
Posted in Jira Service Management

Jira Service Management Documentation Opportunities

Hello everyone, Hope everyone is safe! A few months ago we posted an article sharing all the new articles and documentation that we, the AMER Jira Service Management team created. As mentioned ...

163 views 0 4
Join discussion

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you