使用Maven和Jenkins分阶段部署快照工件 [英] Staged deployment of snapshot artifacts with Maven and Jenkins

查看:298
本文介绍了使用Maven和Jenkins分阶段部署快照工件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问题描述

我们有几个相互依赖的多模块项目.像这样:

  • 消息传递
  • 框架
  • 其他组件

他们有单独的源代码控制存储库,并且可以说消息 othercomponent 中的子模块正在使用来自 framework 子模块的捆绑软件.所有项目都是基于OSGI的多模块Maven项目.它们全部都有一个服务器部分和一个来源GUI部分(Eclipse RAP + RCP).因此,对于所有这些多模块项目,这最终都基于基于Maven的三步构建(因为Tycho构建不能与普通的旧Maven构建混在一起):

  • 构建服务器部分
  • 构建RAP GUI部件
  • 构建RCP GUI部分

最后还有一个最终产品多模块maven项目(简称为我们的产品),该项目使用消息框架其他组件.项目我们的产品与其他三个具有相同版本号的版本号不同.

我们使用Jenkins构建了整个系统,并且作业之间的依赖关系树相互触发.该公司决定使用快照在3个框架项目开发人员和我们的产品开发人员之间获取更直接,更快速的反馈.这可能是一个不错的主意,但是存在很大的问题.

如果在构建链中发生了某些故障,则快照存储库将包含无法一起工作的消息框架其他组件的快照.这样,我们的产品的开发人员就必须等待有效的快照集(否则他们甚至无法编译一段时间).另一个问题是,在构建期间,快照集也不一致.

想法

对于消息框架其他组件,詹金斯(Jenkins)中有明确的最终工作.如果完成,则快照组必须正常工作,因此我们的产品团队可以使用它. 因此,我需要以某种方式收集由构建链创建的快照,并仅在整个构建链成功后才部署快照.

  • 是否有这样做的可能性?

我的想法是简单地将作业更改为仅进行 install 而不进行 deploy .然后最后,我可以在本地Maven存储库中查找已构建的快照,并通过脚本进行部署.

  • Maven有一些暂存概念(可能仅适用于Nexus pro).它是否说明了快照?

任何想法都值得欢迎.但是我不能改变使用快照的事实.因此说服我使用发行版和快照没有任何用处.

解决方案

解决方案

我找到了一个不错的解决方法.采取的步骤:

  1. 构建步骤必须使用 altDeploymentRepository 参数而不是常规目标存储库部署到临时文件夹(请参阅 解决方案

Solution

I have found a nice workaround. Steps to take:

  1. The build steps have to deploy to a temp folder instead of the normal target repository using the altDeploymentRepository parameter (see http://maven.apache.org/plugins/maven-deploy-plugin/deploy-mojo.html)

    mvn deploy -DaltDeploymentRepository=stagingFolder::default::file:///c:/mytempfolder

  2. Run any number of build steps with this setting, and the artifacts are collected in the folder. You can even resume the builds without problem. You can overwrite artifacts (i do not recommend it however)

  3. You have to run the following command after completing all build steps (see http://mojo.codehaus.org/wagon-maven-plugin/copy-mojo.html). This uploads all artifacts which were collected temporarly in the folder:

    mvn org.codehaus.mojo:wagon-maven-plugin:copy -Dwagon.source=file:///c:/mytempfolder -Dwagon.target=http://somerepository.com/repositories/snapshots -Dwagon.targetId=idreferredinsettingsxmltogetauthorization

Important Note

The wagon goal should be run in a folder, where there is no pom file (so it must be run without project). Otherwise there is a weird error with the fromDir parameter.

Known Limitations

  1. The build steps should run using the same local repository, since if the steps need the artifacts produced by other artifacts, they can find it in the local repository.
  2. This solution does not read the POM to get the repository to which the artifacts should be uploaded. This is wired today into the wagon command. But I can live with it now :)

这篇关于使用Maven和Jenkins分阶段部署快照工件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆