Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root


1 badge earned


Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!


Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.


Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!


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
JamieA Rising Star Apr 15, 2014

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. :)

JamieA Rising Star Jun 22, 2014

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.

0 votes

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

Atlassian Community Events