1

tl; dr: mvn clean install按预期工作,但 Jenkins 无法解析子 pom 中的变量。

我们有一个包含一个主 pom 和多个子 pom 的项目。它似乎在 sub pom 中失败,变量${project.version}没有被解析(请参阅下面的错误消息并滚动到其末尾)。

主要的pom:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>group</groupId>
    <artifactId>artifact</artifactId>
    <version>1.0.0.0-SNAPSHOT</version>
    ...
</project>

子pom:

<parent>
    <groupId>group</groupId>
    <artifactId>artifact</artifactId>
    <version>${project.version}</version>
    <relativePath>../pom.xml</relativePath>
</parent>

mvn clean install在控制台上完美运行:

[INFO] Installing /path/to/jenkins/workspace/Project/pom.xml to /path/to/.m2/repository/de/project/1.0.0.0-SNAPSHOT/project-1.0.0.0-SNAPSHOT.pom
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
...
[INFO] PROJECT 1.0.0.0-SNAPSHOT - EAR project ........... SUCCESS [  5.038 s]
[INFO] PROJECT 1.0.0.0-SNAPSHOT - Aggregator project ........ SUCCESS [  0.156 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 01:03 min
[INFO] Finished at: 2016-09-20T12:58:03+02:00
[INFO] Final Memory: 104M/1088M
[INFO] ------------------------------------------------------------------------

Jenkins 无法解析 pom 并产生以下错误:

Parsing POMs
ERROR: Failed to parse POMs
org.apache.maven.project.ProjectBuildingException: Some problems were encountered while processing the POMs:
[FATAL] Non-resolvable parent POM: Failure to transfer my.package:project:pom:${project.version} from http://mynexus.com/content/groups/default was cached in the local repository, resolution will not be reattempted until the update interval of nexus-default has elapsed or updates are forced. Original error: Could not transfer artifact my.package:project:pom:${project.version} from/to nexus-default (http://mynexus.com/content/groups/default): Illegal character in path at index 78: http://mynexus.com/content/groups/default/my/package/project/${project.version}/panda-${project.version}.pom and 'parent.relativePath' points at wrong local POM @ line 26, column 10

为了让 Jenkins 也可以解析 pom 文件,必须进行哪些更改?

链接的问题指出,maven 将无法解析孩子的属性,因为它们不存在。上面的 maven 日志表明情况并非如此。

以上信息已编辑。错别字不是这个问题的原因。

4

1 回答 1

0

我通过使用 Freestyle 项目 Job 而不是 Maven 项目 Job 来修复它。在shell或本地运行本机maven命令没有这个问题。

类似的错误: JENKINS-23846

于 2016-11-04T05:13:48.717 回答