简体   繁体   English

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

[英]Jenkins Config File Maven Multiple Nexus Repositories Download

So I want to setup a config file in Jenkins for a Maven project to use multiple repositories. 因此,我想在Jenkins中设置一个配置文件,以便Maven项目使用多个存储库。 The whole idea is to try and download from one if it cannot be found then download from the second one. 整个想法是尝试从一个下载失败,然后从第二个下载。 Below is what I have configured now and from the Jenkins logs, I can see it 'downloading' from both repositories. 以下是我现在配置的内容,以及从Jenkins日志中可以看到的内容,它们可以从两个存储库中“下载”。

The problem is that it doesn't actually fallback if it can't find it in the first one it simply fails so something is wrong. 问题是,如果它在第一个中找不到它就不会真正回退,它只是失败了,所以出了点问题。 I have to add that everything works fine if I use either of them exclusively so it's not a connectivity issue are anything else like that. 我必须补充一点,如果我只使用它们中的任何一个,那么一切都可以正常工作,因此与其他类似的问题都不是连接问题。 Please help I have been at this for a day and a half now and I am fairly sure it's because I can't wrap my mind around the Maven Documentation. 请帮忙,我已经待了一天半了,我很确定这是因为我不能把心思放在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>

By using 通过使用

<mirrorOf>*</mirrorOf>

you set the repository as mirror of everything , so every request is redirected to the NEW_NEXUS/nexus/repository/maven-public repository. 您将存储库设置为所有内容的镜像,因此每个请求都被重定向到NEW_NEXUS/nexus/repository/maven-public存储库。

What you usually do: 您通常做什么:

Go into the Nexus as administrator and define a repository group which contains both repositories. 以管理员身份进入Nexus并定义一个包含两个存储库的存储库组 Then just use this repository group as mirror of everything. 然后,只需将此存储库组用作所有内容的镜像即可。 The Nexus repository group behaves as you expect: It goes through all the repositories until it finds the requested artifact. Nexus存储库组的行为符合您的预期:遍历所有存储库,直到找到请求的工件。

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

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