首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Maven友好的CI -修订属性不适用于Jenkins构建

Maven友好的CI -修订属性不适用于Jenkins构建
EN

Stack Overflow用户
提问于 2021-08-12 15:42:36
回答 2查看 1.2K关注 0票数 2

我试图在我的多模块项目中使用maven友好ci。我的项目有三个父级子层次结构,即我的父项目几乎没有子项目,而这些子项目中有许多其他子项目。

我在下面添加了我的pom文件的示例。我的父母pom也有一个扁平的插件,在我的本地机器上一切都很好。但当我用詹金斯做的时候,它就没用了。我得到下面的错误

错误

错误在处理POMs:致命的、不可解决的父POM时遇到了一些问题:com.farkan:子模块:未知版本:无法将工件com.Faskan:父-模块:pom:${revision}从/转到连接。

父项目的pom.xml

代码语言:javascript
复制
<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

代码语言:javascript
复制
<?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>

儿童项目(大儿童)

代码语言:javascript
复制
<?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>

我发现了一个类似的问题,在使用CI友好版本时,如何在Jenkins中构建maven子项目?。不确定我的是否是相同的,因为我没有任何解析失败错误。

EN

回答 2

Stack Overflow用户

发布于 2022-03-12 20:17:15

在您的父pom.xml中缺少扁平插件的以下配置:

代码语言:javascript
复制
<configuration>
  <updatePomFile>true</updatePomFile>
  <flattenMode>resolveCiFriendliesOnly</flattenMode>
</configuration>  

我相信您必须为ci友好项目添加此配置,如这里所解释的那样。

票数 1
EN

Stack Overflow用户

发布于 2021-08-12 15:48:32

在……里面

代码语言:javascript
复制
    <parent>
        <groupId>org.faskan</groupId>
        <artifactId>parent-module</artifactId>
        <version>${revision}</version>
    </parent>

你不能让${revision}version。梅文不知道从哪里弄来的。你需要使用实际版本。

PS:我不知道你们是如何在当地建造的。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/68760474

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档