Which settings.xml is used by jenkins slave?

旧街凉风 提交于 2019-12-05 18:39:45

问题


I have a Jenkins master (running on a small Linux box) and a Jenkins slave (running on a "correct" XP machine).

I have configured both for all jibs to be run on the Windows XP slave.

Unfortunatly, each time a build is run on that slave, the build fails due to the following error :

ERROR: Ignore Problem expanding maven opts macros org.jenkinsci.plugins.tokenmacro.TokenMacro
Found mavenVersion 3.0.3 from file jar:file:/E:/java-ext/apache-maven-3.0.3/lib/maven-core-3.0.3.jar!/META-INF/maven/org.apache.maven/maven-core/pom.properties
Parsing POMs
ERROR: Echec à la lecture des POMs
hudson.util.IOException2: remote file operation failed: C:\hudson\workspace\Autocat at hudson.remoting.Channel@ee5bc4:ndx-PC-winXP
    at hudson.FilePath.act(FilePath.java:752)
    at hudson.FilePath.act(FilePath.java:738)
    at hudson.maven.MavenModuleSetBuild$RunnerImpl.parsePoms(MavenModuleSetBuild.java:817)
    at hudson.maven.MavenModuleSetBuild$RunnerImpl.doRun(MavenModuleSetBuild.java:617)
    at hudson.model.AbstractBuild$AbstractRunner.run(AbstractBuild.java:429)
    at hudson.model.Run.run(Run.java:1374)
    at hudson.maven.MavenModuleSetBuild.run(MavenModuleSetBuild.java:467)
    at hudson.model.ResourceController.execute(ResourceController.java:88)
    at hudson.model.Executor.run(Executor.java:145)
Caused by: hudson.remoting.ProxyException: hudson.maven.MavenModuleSetBuild$MavenExecutionException: org.apache.maven.project.ProjectBuildingException: Some problems were encountered while processing the POMs:
[FATAL] Non-resolvable parent POM: Failure to find fr.perigee.java:java-parent:pom:0.0.6 in http://tinkerpop.com/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of tinkerpop has elapsed or updates are forced and 'parent.relativePath' points at wrong local POM @ line 3, column 10

I know this error is due to the bad definition of repository containing those artifacts, because used repository is defined in settings.xml. So, my question is quite simple : how can I define which settings.xml file is used by a Jenkins slave ?


回答1:


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.




回答2:


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 !




回答3:


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



来源:https://stackoverflow.com/questions/7807171/which-settings-xml-is-used-by-jenkins-slave

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