Re: Change path of .m2 directory if using maven-plugin

2,946 views
Skip to first unread message

Richard Mortimer

unread,
Mar 20, 2012, 8:35:58 AM3/20/12
to jenkins...@googlegroups.com, Programie
Hi,

You question is best addressed to jenkins...@googlegroups.com.
jenkinsci-issues@ is used for automated JIRA messages.

That said I've answered your question below etc. and posted to -users
for others to comment as appropriate.

On 20/03/2012 11:39, Programie wrote:
> Hi,
>
> I'm using Jenkins with the Maven plugin. Jenkins is running in a Tomcat
> container.
>
> Tomcat is running using the wwwjenkins user. However the home directory of
> this user does not exist. The administrators of the server said me, they set
> it to an invalid directory to have an unique directory for each application.
> That may makes sense because multiple applications can run in the same user
> context.
>
> The problem: Maven tries to create the .m2 directory in the not existing
> home directory of the wwwjenkins user. How can I change the path used by
> Maven for the .m2 directory? I want to move it to JENKINS_HOME.
>

If you navigate to the "Manage Jenkins" page you can set the location of
the .m2 directory in the "Maven Project Configuration" section.

<yourjenkinsurl>/configure


You can set it to be "Local to executor" or "Local to workspace". I
suspect that you want "Local to workspace".

Regards

Richard

Michael Wieland

unread,
Mar 20, 2012, 8:53:09 AM3/20/12
to jenkins...@googlegroups.com, Programie
Hi,

thanks for your reply but that didn't solved the problem. :(

This option only changes the location of the local repository. The path to the .m2 directory does not change by using this option.

A build fails with this error message:
ERROR: Failed to create /not/existing/user/dir/.m2

I've looked at the source code of the maven-plugin and saw the path is hard coded to the property "user.home". Is there any way to set the user.home property in a Maven job?


Regards

Michael


On Tuesday, March 20, 2012 1:35:58 PM UTC+1, Richard Mortimer wrote:
Hi,

You question is best addressed to jenkinsci-users@googlegroups.com.

domi

unread,
Mar 20, 2012, 2:20:56 PM3/20/12
to jenkins...@googlegroups.com
add "-Duser.home=/oath/toNewDir" to the options
/Domi

Michael Wieland

unread,
Mar 20, 2012, 3:26:56 PM3/20/12
to jenkins...@googlegroups.com
Hi,

I already tried that using the MAVEN_OPTS configuration field. But Maven still uses the old home directory.

Nord, James

unread,
Mar 21, 2012, 5:09:13 AM3/21/12
to jenkins...@googlegroups.com

Jenkins did (does) use the local users repo when it is parsing the POM files (before the invocation of maven on the executor)

 

If you switch to the freestyle job this should work – but you will loose all of the goodness that comes with the Maven2 type job.

 

But – as you’re administrators expect this to be set per web-app in the app server why don’t you ask them to configure it for you on the app server?

 

/James

 

From: jenkins...@googlegroups.com [mailto:jenkins...@googlegroups.com] On Behalf Of Michael Wieland
Sent: 20 March 2012 19:27
To: jenkins...@googlegroups.com
Subject: Re: Change path of .m2 directory if using maven-plugin

 

Hi,

 

I already tried that using the MAVEN_OPTS configuration field. But Maven still uses the old home directory.

 


On Tuesday, March 20, 2012 7:20:56 PM UTC+1, domi wrote:

add "-Duser.home=/oath/toNewDir" to the options

/Domi

 

 

On 20.03.2012, at 13:53, Michael Wieland wrote:



Hi,

 

thanks for your reply but that didn't solved the problem. :(

 

This option only changes the location of the local repository. The path to the .m2 directory does not change by using this option.

 

A build fails with this error message:

ERROR: Failed to create /not/existing/user/dir/.m2

 

I've looked at the source code of the maven-plugin and saw the path is hard coded to the property "user.home". Is there any way to set the user.home property in a Maven job?

 

 

Regards

 

Michael

 


On Tuesday, March 20, 2012 1:35:58 PM UTC+1, Richard Mortimer wrote:

Hi,

You question is best addressed to jenkins...@googlegroups.com.


jenkinsci-issues@ is used for automated JIRA messages.

That said I've answered your question below etc. and posted to -users
for others to comment as appropriate.

On 20/03/2012 11:39, Programie wrote:
> Hi,
>
> I'm using Jenkins with the Maven plugin. Jenkins is running in a Tomcat
> container.
>
> Tomcat is running using the wwwjenkins user. However the home directory of
> this user does not exist. The administrators of the server said me, they set
> it to an invalid directory to have an unique directory for each application.
> That may makes sense because multiple applications can run in the same user
> context.
>
> The problem: Maven tries to create the .m2 directory in the not existing
> home directory of the wwwjenkins user. How can I change the path used by
> Maven for the .m2 directory? I want to move it to JENKINS_HOME.
>

If you navigate to the "Manage Jenkins" page you can set the location of
the .m2 directory in the "Maven Project Configuration" section.

<yourjenkinsurl>/configure


You can set it to be "Local to executor" or "Local to workspace". I
suspect that you want "Local to workspace".

Regards

Richard

 

 

 

 

 

 

 

 




**************************************************************************************
This message is confidential and intended only for the addressee. If you have received this message in error, please immediately notify the postm...@nds.com and delete it from your system as well as any copies. The content of e-mails as well as traffic data may be monitored by NDS for employment and security purposes. To protect the environment please do not print this e-mail unless necessary.

NDS Limited. Registered Office: One London Road, Staines, Middlesex, TW18 4EX, United Kingdom. A company registered in England and Wales. Registered no. 3080780. VAT no. GB 603 8808 40-00
**************************************************************************************

Michael Wieland

unread,
Mar 21, 2012, 6:04:15 AM3/21/12
to jenkins...@googlegroups.com
OK, that would be the best option. But I heard you can only change the property for all webapps using the CATALINA_OPTS environment variable.

Is there a way to just change it for one webapp?

They said me, they are "just" administrators but have no knowledge about Java... So I also have to search for the solution to set the property in Tomcat.



On Wednesday, March 21, 2012 10:09:13 AM UTC+1, teilo wrote:

But – as you’re administrators expect this to be set per web-app in the app server why don’t you ask them to configure it for you on the app server?

 

From: jenkinsci-users@googlegroups.com [mailto:jenkinsci-users@googlegroups.com] On Behalf Of Michael Wieland
Sent: 20 March 2012 19:27
To: jenkinsci-users@googlegroups.com
Subject: Re: Change path of .m2 directory if using maven-plugin

 

Hi,

 

I already tried that using the MAVEN_OPTS configuration field. But Maven still uses the old home directory.

 


On Tuesday, March 20, 2012 7:20:56 PM UTC+1, domi wrote:

add "-Duser.home=/oath/toNewDir" to the options

/Domi

 

 

On 20.03.2012, at 13:53, Michael Wieland wrote:



Hi,

 

thanks for your reply but that didn't solved the problem. :(

 

This option only changes the location of the local repository. The path to the .m2 directory does not change by using this option.

 

A build fails with this error message:

ERROR: Failed to create /not/existing/user/dir/.m2

 

I've looked at the source code of the maven-plugin and saw the path is hard coded to the property "user.home". Is there any way to set the user.home property in a Maven job?

 

 

Regards

 

Michael

 


On Tuesday, March 20, 2012 1:35:58 PM UTC+1, Richard Mortimer wrote:

Hi,

You question is best addressed to jenkinsci-users@googlegroups.com.

Alec Disharoon

unread,
Jan 4, 2013, 12:39:24 PM1/4/13
to jenkins...@googlegroups.com
I'm having this issue, too.  Since we already set a JENKINS_HOME, shouldn't that be used, instead of whatever user.home is set to?  For me, Jenkins is running under Tomcat from Ubuntu's apt repository, so it is running as the tomcat7 user which has a home of /usr/share/tomcat7, which isn't writable by the tomcat7 user.  Looking at JIRA and googling around, it doesn't appear that anyone else thinks this is a problem, so maybe I am not understanding something.  

I realize that ~/.m2 is the standard, but I can't think of any reason why this standard should be adhered to so strictly that no customization is allowed, even for non-recommended cases.  

Alec
Reply all
Reply to author
Forward
0 new messages