我们有许多Java项目,它们是使用Jenkins构建的CI . 这些部署到我们自己的Nexus服务器就好了 . 问题是,我们需要将这些库提供给第三方,但没有源代码 . 因此,对于每个项目,在Nexus中我们有:
-
为我们的开发者发布存储库(包括已部署的源代码)
-
我们开发人员的快照存储库(包括已部署的源代码)
-
第三方发布存储库(仅限JAR POM)
-
(并且很高兴):第三方快照存储库(仅限JAR POM)用于第三方夜间构建
问题是:在Jenkins / Nexus世界中,这通常是如何处理的?我'd prefer to have one single Job in Jenkins which handles the CI build and the release (artefact deployment) process 2623962 . Currently I'在我们的"main root pom.xml"中使用了多个 <distributionManagement>
Profiles (包含在所有项目中):
[...]
<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文档中,似乎无法在同一构建生命周期中使用多个存储库,更不用说我们需要/不需要基于目标存储库的源 .
我可以在Jenkins中创建一个Job,然后使用Maven "Goals and options": clean deploy -P third-party
,然后使用"default"数据添加Post-build操作 - "Deploy artifacts to Maven repository" - 但在这种情况下,只有SNAPSHOT会同时通过Jenkins Maven Release Plug-in释放repo和artefacts只进入一个存储库 .
任何实用的想法如何在不过度复杂CI作业层次结构的情况下实现这一目标?
提前致谢!
2 回答
你可以在Nexus中处理这一切 . 创建一个存储库目标,其中包含类似于预配置示例“All but sources(Maven 2)”中使用的模式,并使用另一个限制groupid,artifactid甚至版本的模式进一步缩小目标 .
然后创建一个使用该存储库目标的权限,并将其分配给您希望具有相应访问权限的用户或角色 .
无需进行多次部署或某些此类..
见http://books.sonatype.com/nexus-book/reference/repository-targets.html
您可以使用Maven Wagon Plugin并在部署阶段将单个jar上传到远程位置 .