Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Relative path for groovy script?

Tarun Sapra
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
January 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 votes
Answer accepted
JamieA
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 15, 2015

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 Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
January 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?

0 votes
Tarun Sapra
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
January 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.

0 votes
MichałS
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 14, 2015

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 Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
January 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. "/"

0 votes
JamieA
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 14, 2015

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 Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
January 14, 2015

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

0 votes
JamieA
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 14, 2015

It should work.

0 votes
Tarun Sapra
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
January 14, 2015

JIRA 5.2.11 Script runner 2.1.15

0 votes
MichałS
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 14, 2015

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

Suggest an answer

Log in or Sign up to answer