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

This widget could not be displayed.

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?

This widget could not be displayed.

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

This widget could not be displayed.
Tarun Sapra Community Champion Jan 14, 2015

JIRA 5.2.11 Script runner 2.1.15

This widget could not be displayed.

It should work.

This widget could not be displayed.
Tarun Sapra Community Champion Jan 14, 2015

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

This widget could not be displayed.

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")

This widget could not be displayed.
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. "/"

This widget could not be displayed.

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

This widget could not be displayed.
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 Sign up to answer
Atlassian Summit 2018

Meet the community IRL

Atlassian Summit is an excellent opportunity for in-person support, training, and networking.

Learn more
Community showcase
Posted Wednesday in New to Jira

Are you planning to trial, or are currently trialling Jira Software? - We want to talk to you!

Hello! I'm Rayen, a product manager at Atlassian. My team and I are working hard to improve the trial experience for Jira Software Cloud. We are interested in   talking to 20 people planning t...

83 views 1 0
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