2017-08-04 78 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中的哪一個可以到達,哪些不是? –