mvn deploy -DaltDeploymentRepository = stagingFolder :: default :: file:///c:/mytempfolder 使用此设置运行任意数量的构建步骤,并且工件被收集在文件夹中.您甚至可以毫无问题地恢复构建.您可以覆盖工件(但是我不建议这样做) 您必须在完成所有构建步骤后运行以下命令(请参见 http://mojo.codehaus.org/wagon-maven-plugin/copy-mojo.html ).这会上载临时收集在文件夹中的所有工件: mvn org.codehaus.mojo:wagon-maven-plugin:copy -Dwagon.source = file:///c:/mytempfolder -Dwagon.target = http://somerepository.com/repositories/snapshots -Dwagon.targetId = idreferredinsettingsxmltogetauthorization重要提示旅行车目标应在没有pom文件的文件夹中运行(因此必须在没有项目的情况下运行).否则, fromDir 参数会出现奇怪的错误.已知限制构建步骤应使用相同的本地存储库运行,因为如果这些步骤需要其他工件产生的工件,它们可以在本地存储库中找到它.此解决方案不读取POM来获取应将工件上载到的存储库.今天已将其连接到wagon命令中.但是我现在可以忍受它了:)Problem DescriptionWe have several multi-module projects which are depending on each other. So something like this:messagingframeworkothercomponentThey have separate source control repository, and lets say, that submodules inside messaging and othercomponent are using bundles from the submodules of framework. All of the projects are OSGI based multi-module maven projects. All of them have a server part, and a single sourced GUI part (Eclipse RAP+RCP). So this ends up in a three step maven based build for all of these multi-module projects (since Tycho builds cannot be mixed with plain old Maven Builds):Building server partBuilding RAP GUI partBuilding RCP GUI partAnd finally there is an end product multi-module maven project (lets call it ourproduct), which uses messaging, framework and othercomponent. The project ourproduct has different version number than the other three, which are having a common version number.We build the whole thing with Jenkins, and the jobs trigger each other depending on the dependency tree. The company decided to use snapshots to get more direct and fast feedback between the 3 framework project developers and the ourproduct developers. This can be a nice idea, however there is a big problem.If during the building chain something is broken, than the snapshot repository contains snapshots of messaging, framework and othercomponent, which cannot work together. This way the developers of ourproduct have to wait for a working snapshot set (otherwise they cannot even compile some time). An other problem is that during the build the set of snapshots are also not consistent.IdeaFor the messaging, framework and othercomponent there is a definite end job in Jenkins. If that finishes, then the set of snapshots must be working, so the ourproduct team could use it. So i would need to COLLECT somehow the snapshots created by the build chain, and deploy them only if the whole build chain was successful.Is there any existing possibility to do this?My idea was to simply change the jobs to make only install only and not deploy. Then at the end I could look for the built snapshots in the local maven repo, and deploy them by a script.There is some Staging Concept for Maven (maybe only with Nexus pro). Does it say anything about snapshots?Any idea is welcome. However i cannot change the fact of using snapshots. So there is no use in convincing me to use releases and no snapshots. 解决方案 SolutionI have found a nice workaround. Steps to take: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:/mytempfolderRun 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)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=idreferredinsettingsxmltogetauthorizationImportant NoteThe 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 LimitationsThe build steps should run using the same local repository, since ifthe steps need the artifacts produced by other artifacts, they canfind it in the local repository.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分阶段部署快照工件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!