Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

How to I access the jira home directory from inside a Jira plugin?

Sorin Sbarnea (Citrix)
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.
April 15, 2012

How to I access the jira home directory from inside a Jira Java listener plugin?

I am writing a listener and I do not know how to get the jira home directory and I do not want to hardcode the path to it.

3 answers

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

7 votes
Answer accepted
Igor Sereda [ALM Works]
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.
April 17, 2012

I also don't think Jamie's answer is the right way -- you'd better try

import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.config.util.JiraHome;
...
ComponentAccessor.getComponentOfType(JiraHome.class).getHome()

I second Jamie's comment that there's no "install directory". If you have your custom scripts, you'd be better off by putting them into some sub-directory under JIRA home.

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.
April 17, 2012

Yeah you're right, my answer is not strictly correct. But I got the points, which is all that matters ;-)

Igor Sereda [ALM Works]
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.
April 17, 2012

:) .

Sorin Sbarnea (Citrix)
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.
April 23, 2012

Excuse my Java newbie question but your example is a little bit incomplete, it does not compile because it does not find the JiraHome.class - which seams to be just interface. Can you improve it a little bit? Also, add the required `import com.atlassian.jira.component.ComponentAccessor;`

Igor Sereda [ALM Works]
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.
April 23, 2012

Of course you need to import JiraHome and ComponentAccessor - are you using any Java IDE? They would suggest and add import statements automatically.

Jeremy Largman
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
November 29, 2012

Thanks, this worked for me. Full statement, with imports:

import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.config.util.JiraHome;
...
ComponentAccessor.getComponentOfType(JiraHome.class).getHome()

2 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.
April 15, 2012
import com.atlassian.jira.config.util.DefaultJiraHome

new DefaultJiraHome().getHome()

Although I don't think this is the right way... can't find the manager class for this atm.

Sorin Sbarnea (Citrix)
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.
April 17, 2012

The funny part was the in fact I was looking for Jira install directory not the home directory, but your answer is correct for this question. Does it happen to know the other one too?

Sorin Sbarnea (Citrix)
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.
April 17, 2012

Thats easy to say, but I do have few scripts that are currently called with full paths /root/scripts/ and I'm moving them inside jira installation directory.

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.
April 17, 2012

I don't think you should need to know it... it might be app server specific. Eg catalina.base system property on tomcat.

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.
April 17, 2012

What kind of scripts? I'd move them out of the install dir, and use relative paths or a system property for the location.

Mizan
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 31, 2013

Hi Jamie ,

I am using the above methods provided by you and Igor in a groovy script for behaviours plugin , but i get an exception that unable to resolve class DefaulltJiraHome , can you please suggest what i can do to resolve this ?

Thanks

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 31, 2013

Can you import JiraHome? That is the right way to do it...

Mizan
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.
February 1, 2013

For both JiraHome and DefaultJiraHome i get an unable to resolve class exception for my script

0 votes
Tony Filipe October 10, 2013

You can also have JiraHome injected into your constructor:

import com.atlassian.jira.config.util.JiraHome;

public class MyOwnComponent {
	private JiraHome jiraHome;
	
	public MyOwnComponent (JiraHome jiraHome) {
		this.jiraHome = jiraHome;
	}

(This also works for an action that extends JiraWebActionSupport)

[Jira 6, Plugin SDK 4.2.9]

TAGS
AUG Leaders

Atlassian Community Events