简体   繁体   English

Maven在Jenkins上失败(目标存储库不能为空),但不是本地的

[英]Maven fails on Jenkins (Target repository cannot be empty) but not local

I have a simple maven project that successfully runs local but fails when running on Jenkins. 我有一个简单的maven项目,该项目可以在本地成功运行,但是在Jenkins上运行时却失败。

The pom.xml: pom.xml:

<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>org.example.abc.test</groupId>
    <artifactId>dev-test</artifactId>
    <packaging>pom</packaging>
    <version>1.0.0-SNAPSHOT</version>
    <name>DEV-TEST</name>
    <modules>
        <module>dev-test-abc</module>
        <module>dev-test-assemblies</module>
    </modules>
    <distributionManagement>
        <repository>
            <id>artifactory.example.org</id>
            <name>artifactory.example.org-releases</name>
            <url>http://artifactory.example.org:8081/artifactory/project-releases</url>
        </repository>
        <snapshotRepository>
            <id>artifactory.example.org</id>
            <name>artifactory.example.org-snapshots</name>
            <url>http://artifactory.example.org:8081/artifactory/project-snapshots</url>
        </snapshotRepository>
    </distributionManagement>
    <repositories>
        <repository>
            <id>artifactory</id>
            <name>Artifactory maven repository</name>
            <url>http://artifactory.example.org:8081/artifactory/repo</url>
            <releases>
                <enabled>true</enabled>
                <updatePolicy>always</updatePolicy>
            </releases>
            <snapshots>
                <enabled>true</enabled>
            </snapshots>
        </repository>
    </repositories>
    <pluginRepositories>
        <pluginRepository>
            <id>plugin-artifactory</id>
            <name>Artifactory maven repository</name>
            <url>http://artifactory.example.org:8081/artifactory/repo</url>
            <releases>
                <enabled>true</enabled>
                <updatePolicy>always</updatePolicy>
            </releases>
            <snapshots>
                <enabled>true</enabled>
            </snapshots>
        </pluginRepository>
    </pluginRepositories>
</project>

I run it local with mvn clean install on Jenkins it fails with the maven plugin. 我在Jenkins上使用mvn clean install在本地运行,但使用maven插件失败。

On Jenkins I got following: 在詹金斯,我得到了以下关注:

[INFO] DEV-TEST::ABC ......................... FAILURE [  2.928 s]
[INFO] DEV-TEST::ASSEMBLIES .................. SKIPPED
[INFO] DEV-TEST .............................. SKIPPED
[INFO] ------------------------------------------------------------------------
... ... ...
[INFO] ------------------------------------------------------------------------
[ERROR] Internal error: java.lang.IllegalArgumentException: Target repository cannot be empty -> [Help 1]
org.apache.maven.InternalErrorException: Internal error: java.lang.IllegalArgumentException: Target repository cannot be empty
    at org.apache.maven.lifecycle.internal.builder.BuilderCommon.handleBuildError(BuilderCommon.java:147)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:129)

The pom of the failing module is here: 故障模块的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>
    <parent>
        <groupId>org.example.abc.test</groupId>
        <artifactId>dev-test</artifactId>
        <version>1.0.0-SNAPSHOT</version>
    </parent>
    <artifactId>dev-test-abc</artifactId>
    <name>DEV-TEST::ABC</name>
    <version>1.0.0-SNAPSHOT</version>
</project>

As it is running local I guess that it is something with the maven settings that are in "C:/users/USER/.m2/settings.xml" is there something that could cause that error - that could be moved to the project pom to make it possible building on Jenkins with success? 因为它在本地运行,所以我猜它与“ C:/users/USER/.m2/settings.xml”中的Maven设置有关,可能会导致该错误-可以移至项目pom使成功建立在詹金斯上成为可能?

As a note: Other Projects on the Jenkins building successful - so I guess it is something missing in the POM. 需要注意的是:詹金斯大厦上的其他项目都取得了成功-因此我想POM中缺少这一点。

Make sure you select target repository however looks is missing the publisher tag. 确保选择目标存储库,但是看起来缺少发布者标记。 You can use plugin called maven artifactory the link below there are examples and guide about it: 您可以使用名为maven artifactory的插件,下面的链接提供了示例和指南:

artifactory-maven-plugin-example-and-guide artifactory的-行家-插件-示例和引导

Check the version of the Artifactory plugin. 检查Artifactory插件的版本。 See: https://www.jfrog.com/jira/browse/HAP-241 参见: https : //www.jfrog.com/jira/browse/HAP-241

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM