2017-08-04 139 views
0

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

问题是,如果它在第一个中找不到,它实际上不会回退,它只是失败了,所以出现了问题。我必须补充一点,如果我专门使用它们中的任何一个,那么一切都可以正常工作,所以它不是一个连接问题。请大家帮忙我一直在这里待了一天半,我确信这是因为我无法将自己的想法包裹在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

通过使用

<mirrorOf>*</mirrorOf> 

您设置的存储库作为一切的镜子,所以每一个请求重定向到NEW_NEXUS/nexus/repository/maven-public库。

你平时做的:

走进了Nexus作为管理员定义包含两个库一库组。然后,只需使用此存储库组作为所有内容的镜像。 Nexus存储库组的行为与您的预期相同:它会遍历所有存储库,直到找到请求的工件。

+0

感谢您的快速回答。所涉及的2个Nexus在一个意义上是2.0.6和另一个是3.3.1,它们也被托管在2个不同的企业环境中,并且它们不能相互交谈。至少在此刻。我不是一个真正的DEVOPS家伙,所以这就是我想这也 新的Nexus !老关系,为什么我学习,我沿着 – nbaprophet

+0

去,*,它仍然无法正常工作 – nbaprophet

+0

贵詹金斯不知道两个Nexus中的哪一个可以到达,哪些不是? –