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