【发布时间】:2017-03-30 19:50:50
【问题描述】:
我有三个 Jenkins Maven 工作:一个构建和安装依赖项 (JAR),两个使用这些依赖项捆绑可部署的 WAR 文件。
我已将所有三个作业都配置为使用特定的 settings.xml 文件,并且虽然不完全理解 Settings file 和 Global Settings file 之间的区别(即使在阅读了?,也不清楚),在 构建我将两个字段都设置为我希望使用的文件路径,以防万一:
/opt/maven/conf/settings.xml 指定:
<localRepository>/var/lib/maven/repo</localRepository>
但是,依赖项会下载到不同的位置:/var/lib/jenkins/maven-repositories/1 因为/var/lib/jenkins 是JENKINS_HOME。
控制台输出记录以下内容:
执行 Maven:-B -f /var/lib/code/src/pom.xml -Dmaven.repo.local=/var/lib/jenkins/maven-repositories/2 -s /opt/maven/conf/ settings.xml -gs /opt/maven/conf/settings.xml 全新安装 -P depBuild
这令人困惑,因为maven.repo.local 与 -s 和 -gs 下列出的文件所说的不同。
为什么它没有在我告诉它使用的 settings.xml 中指定的本地 repo 中下载和安装依赖项?
这是整个 settings.xml:
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
<localRepository>/var/lib/maven/repo</localRepository>
<servers>
<server>
<id>build.tomcat.all</id>
<username>buildman</username>
<password>mypass</password>
</server>
</servers>
<pluginGroups></pluginGroups>
<proxies></proxies>
<mirrors></mirrors>
<profiles></profiles>
</settings>
【问题讨论】:
-
你能发布完整的 settings.xml 吗?您的源文件中是否还有其他 settings.xml?
-
请看我的更新
-
看起来 Jenkins 在执行 Maven 时使用命令行选项覆盖了本地存储库。该参数可能取自 Jenkins 主目录或安装目录中的
.m2/settings.xml。你能查一下那个位置吗? -
可以在Jenkins的全局工具配置中更改默认的settings.xm。
-
运行作业时,请查看控制台输出。它应该打印正在运行的确切内容;包含所有标志和选项的确切行。可能你会看到那里有些东西被覆盖了,这会有所帮助