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

Accepted Answer
0 votes

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 votes
Tarun Sapra Community Champion Jan 14, 2015

JIRA 5.2.11 Script runner 2.1.15

0 votes

It should work.

0 votes
Tarun Sapra Community Champion Jan 14, 2015

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

0 votes

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 votes
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 votes
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
Community showcase
Posted Sep 18, 2018 in Jira

What modern development practices are at the heart of how your team delivers software?

Hey Community mates! Claire here from the Software Product Marketing team. We all know software development changes rapidly, and it's often tough to keep up. But from our research, we've found the h...

22,155 views 2 7
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