Relative path for groovy script?

Tarun Sapra Community Champion Jan 14, 2015

Hi All,

 

I am executing a groovy script file in the workflow post-function.

In the system info. of JIRA i can see - Dcatalina.base=/usr/share/JIRA thus I gave the relative path for the file as groovy/statusUpdate.groovy it didn't work while giving the full qualified path i.e. /usr/share/JIRA/groovy/statusUpdate.groovy works well.

What may be going wrong?

 

JIRA 5.2.11

Script runner 2.1.15

 

Thanks.

9 answers

1 accepted

0 vote

So I don't know why it's using / as working directory. The script paths are resolved relative to the working directory, which is normally but not always catalina.base. 

Not sure I would worry too much because this changes in Script Runner 3.0.

is there a way to specify an env. variable in the script path i.e. ${jira_home}/groovy/myscript.groovy or ${catalina_base}/groovy/myscript.groovy ?

No, in SR 3 you specify one or more scripts directories, and <jira_home>/scripts is automatically a scripts dir. Paths are resolved relative to your scripts dirs.

 


Tarun Sapra Community Champion Jan 15, 2015

Hi Jamie Echlin , thanks for your answer, I think we would need to upgrade to SR 3.0 sooner to latet, just a small query , when using the issue clone functionality in the post function of a transition such that the new issue is create in a new project. In this case is the event "issuce created" for the new project fired?

Hi, could you give more details about the software versions you are using (jira, script runner)?

0 vote
Tarun Sapra Community Champion Jan 14, 2015

JIRA 5.2.11 Script runner 2.1.15

0 vote

It should work.

0 vote
Tarun Sapra Community Champion Jan 14, 2015

Hi @Jamie Echlin [Adaptavist] , but it's not working.

0 vote

yeah but it should... that was all I could think of at the time. Run this in script console and let us know what it reports: System.getProperty("user.dir")

0 vote
Tarun Sapra Community Champion Jan 14, 2015

Hi @Jamie Echlin [Adaptavist] , I executed the code - System.getPoperty("user.dir") in the script console and I get the root as the result i.e. "/"

For one or another reason we also used the full path in JIRA 5.2.x but can't remember why.. Check where your jira-home directory is (JIRA system configuration panel). When checking our system for the property user.dir we get the path to the bin directory of our running jira installation. For some reason the scripts should be placed in the jira-home/scripts directory, but as I said don't remember why. :)

0 vote
Tarun Sapra Community Champion Jan 14, 2015

Hi @Jamie Echlin [Adaptavist] , is there a way to specify an env. variable in the script path i.e. ${jira_home}/groovy/myscript.groovy or ${catalina_base}/groovy/myscript.groovy ? @Michal - In my case - user.fir gives the path of the root dir and only the fully qualified path is working and not the relative path.

Suggest an answer

Log in or Join to answer
Community showcase
Sarah Schuster
Posted Jan 29, 2018 in Jira

What are common themes you've seen across successful & failed Jira Software implementations?

Hey everyone! My name is Sarah Schuster, and I'm a Customer Success Manager in Atlassian specializing in Jira Software Cloud. Over the next few weeks I will be posting discussion topics (8 total) to ...

3,264 views 14 20
Join discussion

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
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot