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.
Community moderators have prevented the ability to post new answers.
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.
Yeah you're right, my answer is not strictly correct. But I got the points, which is all that matters ;-)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
:) .
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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;`
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Of course you need to import JiraHome and ComponentAccessor - are you using any Java IDE? They would suggest and add import statements automatically.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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()
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I don't think you should need to know it... it might be app server specific. Eg catalina.base system property on tomcat.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
What kind of scripts? I'd move them out of the install dir, and use relative paths or a system property for the location.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Can you import JiraHome? That is the right way to do it...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
For both JiraHome and DefaultJiraHome i get an unable to resolve class exception for my script
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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]
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.