Which settings.xml is used by jenkins slave?

孤者浪人 提交于 2019-12-04 02:50:31

Maven uses a global settings and a user settings file. If the user settings file exists, it overrides the global one.

The global one is found in %M2_HOME%\conf\, while the user one is in %HOME%\.m2\. Here %HOME% means the home directory of whatever user is running the Jenkins slave.

So the easiest solution, assuming it is possible in your situation, is to just copy the correct settings.xml file to the %HOME%\.m2\ directory on the Jenkins slave machine.

Alternatively, you can specify a custom settings.xml file on the mvn command line using the --settings option, so you could put the file in a known location (e.g. C:\) and then tell Jenkins to pass the setting to Maven, something like --settings C:\settings.xml.

As an aside, it's often useful to create a new Windows user to run the Jenkins slave, so that you can easily tell where it will search for configuration files.

Like always, solution was simpler than I was thinking it could.

Jenkins slave is configured to be run by the System User. As a consequence, for it to use my settings.xml, all I had to do was changing its associated user, and problem disappeared !

For me what got this to work was using the -Duser.home variable.

I did get this to work! However, instead of entering it into the MAVEN_OPTS, in the configure jenkins screens, I entered it as a JVM level variable to my web server.

For me I'm using glassfish on WinTell, instead of tomcat. Glassfish starts as a windows service. Basically entered:

JVM variable name: user.home JVM value: /data/maven-2.2/jenkins

Then, in this directory /data/maven-2.2/jenkins make sure you have a copy of a valid settings.xml with the proxy info entered correctly. Doing so allows me to isolate a separate settings.xml for my jenkins services builds v. logging on interactively.

Eric

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!