[英]Deploying Maven artifact to multiple repositories with different settings
我們有許多Java項目,它們是使用Jenkins構建的CI。 這些部署到我們自己的Nexus服務器就好了。 問題是,我們需要將這些庫提供給第三方,但沒有源代碼。 因此,對於每個項目,在Nexus中我們有:
問題是:在Jenkins / Nexus世界中,這通常是如何處理的? 我寧願在Jenkins中有一個單獨的Job,它可以“自動”處理CI構建和發布(artefact部署)過程。 目前我在“main root pom.xml”中使用了多個<distributionManagement>
配置文件(包含在所有項目中):
[...]
<profiles>
<profile>
<id>default</id>
<distributionManagement>
<repository>
<id>releases</id>
<name>Release</name>
<url>http://path/to/nexus/content/repositories/releases/</url>
</repository>
<snapshotRepository>
<id>snapshots</id>
<name>Snapshot</name>
<url>http://path/to/nexus/content/repositories/snapshots/</url>
<uniqueVersion>false</uniqueVersion>
</snapshotRepository>
</distributionManagement>
</profile>
<profile>
<id>third-party</id>
<distributionManagement>
<repository>
<id>releases</id>
<name>Release</name>
<url>http://path/to/nexus/content/repositories/third-party/</url>
</repository>
<snapshotRepository>
<id>snapshots</id>
<name>Snapshot</name>
<url>http://path/to/nexus/content/repositories/third-party-snapshots/</url>
<uniqueVersion>false</uniqueVersion>
</snapshotRepository>
</distributionManagement>
</profile>
</profiles>
在Maven文檔中,似乎無法在同一構建生命周期中使用多個存儲庫,更不用說我們需要/不需要基於目標存儲庫的源。
我可以通過使用Maven“目標和選項”在Jenkins中創建Job來完成一個技巧: clean deploy -P third-party
,然后使用“默認”數據添加Post-build操作 - “將工件部署到Maven存儲庫” - 但在這種情況下,只有SNAPSHOT會同時通過Jenkins Maven Release Plug-in發布的repo和artefacts只進入一個存儲庫。
任何實用的想法如何在不過度復雜CI作業層次結構的情況下實現這一目標?
提前致謝!
你可以在Nexus中處理這一切。 創建一個存儲庫目標,其中包含類似於預配置示例“All but sources(Maven 2)”中使用的模式,並使用另一個限制groupid,artifactid甚至版本的模式進一步縮小目標。
然后創建一個使用該存儲庫目標的權限,並將其分配給您希望具有相應訪問權限的用戶或角色。
無需進行多次部署或某些此類..
請參閱http://books.sonatype.com/nexus-book/reference/repository-targets.html
您可以使用Maven Wagon插件並在部署階段將單個jar上傳到遠程位置。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.