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

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Is there a way to have scriptrunner reliably update dependent classes?

We have quite a few scriptrunner items that pull in lists of data to function, one example is we have a table that maps our products to the development team associated with it.  This mapping list shows up in several places; post-functions, listeners, scripted fields, etc... To make updates easier and less prone to mistakes, I moved it to a class (in scripts/Classes).  The problem we are encountering is that updates to the class file are not picked up unless we issue a groovy class/cache reset... which has a domino effect of breaking the custom JQL functions we have loaded, requiring a re-scan.... which breaks some filters, which breaks dashboards, etc.  It can be quite clumsy.

This is mentioned in the documentation, but is there any way to avoid it?  Some super secret handshake or clever trick to assure that changes to a dependent class like the one I mentioned are picked up immediately?

1 answer

I tend to just clear the groovy cache as I don't have the same JQL dependency you describe.

But frequent change to a class file should only happen in a dev/test environment where you shouldn't care about this dependency, and only when doing the final deployment to prod would you need to rescan your JQL.

Maybe someone has a better way ... but if you're willing to give up on some performance, at least in your dev environment, you could always load your class dynamically like this:

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.config.util.JiraHome

jiraHome = ComponentAccessor.getComponent(JiraHome).home
Class YourClass = new GroovyClassLoader(getClass().classLoader).parseClass(new File("$jiraHome/scripts/path/to/YourClass.groovy"))

But that's not suitable for a production environment since the class has to be loaded and compiled each time you use it.

Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Jira

⏰ Day in the life of a Jira Admin!

Hello Community! We thoroughly enjoyed this just-for-fun conversation in the Jira Admin Group about what it's like to be a Jira Admin. For #JiraJuly, our talented designers created these graphics t...

947 views 2 22
Read article

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