Jenkins配置文件Maven多个Nexus存储库下载

时间:2017-08-04 08:50:32

标签: java maven jenkins dependencies nexus

所以我想在Jenkins中为Maven项目设置配置文件以使用多个存储库。整个想法是尝试从一个如果找不到,然后从第二个下载下载。以下是我现在配置的内容,从Jenkins日志中,我可以看到它'下载'来自两个存储库。

问题在于,如果它无法在第一个失败中找到它而实际上没有倒退,那么就会出现问题。我必须补充一点,如果我使用它们中的任何一个都可以正常工作,那么它不是连接问题就是其他类似的东西。请帮助我在这一天工作了一天半,我相当肯定,因为我无法围绕Maven文档进行思考。

[INFO] Downloading: https:NEW_NEXUS/artifact/1.15.0-SNAPSHOT/maven-metadata.xml
[INFO] Downloading: http:OLD_NEXUS/artifact/1.15.0-SNAPSHOT/maven-metadata.xml
[INFO]                   



<?xml version="1.0" encoding="UTF-8"?>

<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 

    http://maven.apache.org/xsd/settings-1.0.0.xsd">

        <mirrors>
            <mirror>
                <id>new-nexus</id>
                <mirrorOf>*</mirrorOf>
                <name>New Nexus Repository</name>
                <url>NEW_NEXUS/nexus/repository/maven-public/</url>
            </mirror>  

            <mirror>
                <id>old-nexus</id>
                <mirrorOf>old-nexus</mirrorOf>
                <name>Old Nexus Repository</name>
                <url>OLD_NEXUS/nexus/content/groups/public/</url>
            </mirror>

        </mirrors>

        <profiles>
            <profile>
                <id>new-nexus</id>
                <repositories>
                    <repository>
                        <id>central</id>
                        <url>http://central</url>
                        <releases>
                            <enabled>true</enabled>
                        </releases>
                        <snapshots>
                            <enabled>true</enabled>
                        </snapshots>
                    </repository>

                    <repository>   
                        <id>old-nexus</id>
                        <name>Old Nexus Repository</name>
                        <url>OLD_NEXUS/nexus/content/groups/public/</url>
                    </repository>

                </repositories>
                <pluginRepositories>
                    <pluginRepository>
                        <id>central</id>
                        <url>http://central</url>
                        <releases>
                            <enabled>true</enabled>
                        </releases>
                        <snapshots>
                            <enabled>true</enabled>
                        </snapshots>
                    </pluginRepository>
                </pluginRepositories>
            </profile>              
        </profiles>

        <activeProfiles>
            <activeProfile>new-nexus</activeProfile>        
        </activeProfiles>

    </settings>

1 个答案:

答案 0 :(得分:1)

使用

<mirrorOf>*</mirrorOf>

您将存储库设置为所有内容的镜像,因此每个请求都会重定向到NEW_NEXUS/nexus/repository/maven-public存储库。

你通常做的事情:

以管理员身份进入Nexus并定义包含两个存储库的存储库组。然后只使用此存储库组作为所有内容的镜像。 Nexus存储库组按预期运行:它遍历所有存储库,直到找到所请求的工件。