简体   繁体   中英

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.

The 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.

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:

<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?

As a note: Other Projects on the Jenkins building successful - so I guess it is something missing in the 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:

artifactory-maven-plugin-example-and-guide

Check the version of the Artifactory plugin. See: https://www.jfrog.com/jira/browse/HAP-241

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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