Jira scriptrunner groovy script refresh/reload

Marc Minten _EVS_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 4, 2017

I have (a lot of) scripts and dependent classes (in subfolders of the script root folder).

When modifying a dependent class, the calling scripts are often still using an "older" version of the dependent class. In the Adaptavist documentation it is stated I should "...modify the calling script by adding whitespace or a comment to get it to recompile...". How to do this if I have a lot of scripts (hundreds!) and making often modifications to the dependent classes (that's where all my business logic is). Is modifying just one dependent script enough ?

2 answers

0 votes
Corey Leighton August 2, 2021

I have a similar issue.  I have a couple of class files where I have some common lists/maps/functions used across several scripts.  If I update anything in those classes, the class isn't automatically reloaded.  While the workaround; clearing the groovy cache, works fine, this breaks the custom JQL functions while the scan runs, which will break filters/boards/reports using those functions.  I've been trying to track down a method to manually call an update of the updated class file without having to flush the entire cache.  If I can do that, I can throw together script to publish to the built-in page and reduce this to a single-click operation that doesn't affect the rest of the system.

If I work out how to do this, I'll post it here.

David Harkins
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 4, 2022

@Corey Leighton Did you make any progress on this ;-) 

Corey Leighton October 4, 2022

@David Harkins I hadn't followed back up with this.  Have I made progress?  Yes, and no... Turns out that flushing the cache was breaking my custom JQL function due to a mismatch in the custom function's class name.  Once I resolved that, a cache flush did not also force me to republish the custom functions.  But if I updated the classes I still had to do a cache reset to get them to go live.

I haven't retested this with a more current version though, but I will and post my results.  

Like David Harkins likes this
0 votes
Daniel Yelamos [Adaptavist]
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 17, 2018

Yes it is. 

If you only add a whitespace to one, that will force recompilation of that script. Which will force recompilation of the class that it extends if the hashes do not match.

So yea don't worry, you only need to modify one of your scripts.

If this solved your answer, please accept the answer so that other users know that this question has been solved.

May I help you further?

Cheers!

DYelamos

Joel January 13, 2021

I've tried this but it doesn't appear to work?

Marc Minten _EVS_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 13, 2021

I have the same issue: sometimes, for unknown reason (no time to investigate further), scripts do not get correctly updated.

Work-around : clear the scriptrunner groovy cache (built-in scripts)

David Harkins
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 4, 2022

The work-around is working for me.

But I don't know how long I can keep editing workflow post functions after every class update when testing.

Is everyone else living with this since the first post in 2017??

Like # people like this

Suggest an answer

Log in or Sign up to answer