Multiple Script roots problem Edited

My product can have two different releases (let's call them release#1 and release#2) running at the same time. Due to incompatible logic, I created two workflows and two sets of scripts and hope each workflow can use its own set of scripts. This mostly is done by configuring multiple script roots by plugin.script.roots JVM option. 

I have two script roots, one is "scripts" and the other one is "scripts/release2." They contain same sub-directory hierarchy and files with same names. For example each root has two files com/company/jira/postfunction/a.groovy and com/company/jira/util/b.groovy.  The release#1 workflow invokes com/company/jira/postfunction/a.groovy and the release#2 invokes ../release2/com/company/jira/postfunction/a.groovy.   Each b.groovy contain a single method called "build" but different signature (i.e. different method arguments). Finally each a.groovy invokes the b.build() method but with different arguments( and a.groovy cotains a line "import com.company.jira.util.b").

The problem is that now  a post function of one release doesn't work due to the method signature mismatch in b.groovy. I think the problem is that both a.groovy uses the same b class loaded by the class loader. 

My question: what's the best practice for a workflow to only use the scripts, invoked directly or indirectly,  from the same script root without changing my package names? 

1 answer

0 vote

Is the "scripts folder" in scripts/release2 the same as the scripts in the other script root? If so this will not work if the files have the same names and package decleration. The classloader will not know which class to load.

Your best off just putting the scripts under one script root, for example under /scripts under the correct folders to match the package decleration.

I'd rename the files so you have something like:
com/company/jira/postfunction/Release1PostFunction.groovy
com/company/jira/postfunction/Release2PostFunction.groovy

As for the shared class you should use a structure like:
com/company/jira/util/Release1Utils.groovy
com/company/jira/util/Release2Utils.groovy

I recognise this is some manual work for you to do, but i think it's really the best way to achieve this.

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published yesterday in Jira Service Desk

Wy are we still using email for Service Desk workflows?

...attest to the experience of an urgent approval that gets lost in the boss’s inbox and requires that special “Please Approve” email or text message. In an age where we have distributed teams...

56 views 0 2
Read article

Atlassian User Groups

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

Find a group

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

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you