【问题标题】:Maven friendly CI - revision property doesn't work with Jenkins buildMaven 友好 CI - 修订属性不适用于 Jenkins 构建
【发布时间】:2021-10-16 00:07:05
【问题描述】:

我正在尝试将maven friendly ci 用于我的多模块项目。我的项目具有三个级别的父子层次结构,即我的父项目的子项目很少,而这些子项目中有许多其他子项目。

我在下面添加了我的 pom 文件示例。我的父 pom 也有一个 flatten 插件,在我的本地机器上一切正常。但是当我从 Jenkins 构建它时,它不起作用。我收到以下错误

错误

[ERROR] [ERROR] 处理过程中遇到了一些问题 POM:[FATAL] 不可解析的父 POM com.faskan:子模块:[未知版本]: 无法转移工件 com.faskan:parent-module:pom:${revision} 从/到 nexus

父项目的 pom.xml

<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <parent>
        <groupId>org.faskan</groupId>
        <artifactId>global-parent-dependency</artifactId>
        <version>1.1.0</version>
    </parent>

    <groupId>org.faskan</groupId>
    <artifactId>parent-module</artifactId>
    <version>${revision}</version>
    <packaging>pom</packaging>

    <name>project parent pom</name>

    <properties>
        <revision>21.15.0-SNAPSHOT</revision>
    </properties>

   <build>
    <plugins>
        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>flatten-maven-plugin</artifactId>
            <version>1.2.2</version>
            <configuration>                
            </configuration>
            <executions>
                <!-- enable flattening -->
                <execution>
                    <id>flatten</id>
                    <phase>process-resources</phase>
                    <goals>
                        <goal>flatten</goal>
                    </goals>
                </execution>
                <!-- ensure proper cleanup -->
                <execution>
                    <id>flatten.clean</id>
                    <phase>clean</phase>
                    <goals>
                        <goal>clean</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>

...
</project>

子项目的 pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<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/xsd/maven-4.0.0.xsd">

    <modelVersion>4.0.0</modelVersion>

    <artifactId>child-module</artifactId>

    <parent>
        <groupId>org.faskan</groupId>
        <artifactId>parent-module</artifactId>
        <version>${revision}</version>
    </parent>

    <name>child admin</name>

    <packaging>jar</packaging>
..
</project>

子项目的子项(孙子)

<?xml version="1.0" encoding="UTF-8"?>
<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/xsd/maven-4.0.0.xsd">

    <modelVersion>4.0.0</modelVersion>
    <artifactId>grand-child-module</artifactId>
    <packaging>jar</packaging>

    <name>child of child module</name>

    <parent>
        <groupId>org.faskan</groupId>
        <artifactId>child-module</artifactId>
        <version>${revision}</version>
    </parent>
..
</project>

我发现了一个类似的问题How do you get maven child projects to build in Jenkins when using CI Friendly versions?。不确定我的是否相同,因为我没有收到任何解析失败错误。

【问题讨论】:

    标签: java maven jenkins jenkins-pipeline maven-3


    【解决方案1】:

        <parent>
            <groupId>org.faskan</groupId>
            <artifactId>parent-module</artifactId>
            <version>${revision}</version>
        </parent>
    

    ${revision} 不能用于 version。 Maven 不知道从哪里得到它。您需要使用实际版本。

    PS:我不知道你是如何在本地构建的。

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-04-26
    • 2012-02-20
    • 2012-05-22
    • 1970-01-01
    • 1970-01-01
    • 2015-08-15
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多