简体   繁体   中英

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

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.

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

What you usually do:

Go into the Nexus as administrator and define a repository group which contains both repositories. 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.

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