简体   繁体   English

如何设置maven选项以运行发布或快照

[英]How to set maven options to run for release or snapshot

I am using a Jenkins server as CI. 我使用Jenkins服务器作为CI。 I am using a maven docker to run the maven tasks. 我正在使用maven docker来运行maven任务。 So here is my problem and my doubts. 所以这是我的问题和我的怀疑。

With jenkins I use the maven plugin to configure and compile the maven tasks. 使用jenkins,我使用maven插件来配置和编译maven任务。 If I want to build I run the Build with Parameters , if I want to create an snapshot or release I run the Perform Maven Release and here I can specify the version. 如果我想构建我运行Build with Parameters ,如果我想创建一个快照或版本,我运行Perform Maven Release ,在这里我可以指定版本。

But with docker is more complicated because I have to use arguments for the mvn command. 但是使用docker会更复杂,因为我必须使用mvn命令的参数。 So: 所以:

How do I set options to create a release or snapshot version? 如何设置选项以创建发行版或快照版?

I have the settings.xml file with my nexus url and also with the user/password, but the problems is using it with docker. 我有我的nexus网址的settings.xml文件以及用户/密码,但问题是它与docker一起使用。

I am using docker.io/maven image. 我正在使用docker.io/maven图片。

Maven handles releases and snapshots based on the version number, not based on the command line arguments. Maven根据版本号处理版本和快照,而不是基于命令行参数。

There is a maven-release-plugin that will automate the work required to release a build; 有一个maven-release-plugin可以自动完成发布版本所需的工作; however, you likely need some background information before you use it. 但是,在使用之前,您可能需要一些背景信息。

To "build a release", you check in a pom.xml which lacks a "-SNAPSHOT" identifier (so you have a history of the source code of the release) and then you build the plugin using the "mvn deploy" command (assuming your pom.xml is fully configured, which it likely isn't). 要“构建一个版本”,您需要检查一个缺少“-SNAPSHOT”标识符的pom.xml(因此您有该版本源代码的历史记录),然后使用“mvn deploy”命令构建插件(假设您的pom.xml已完全配置,可能不是这样。 Then you would check in the "next" -SNAPSHOT version, and everyone would continue developing on the next snapshot version. 然后你将检查“下一步”-SNAPSHOT版本,每个人都将继续开发下一个快照版本。

If this sounds like a lot of work, keep in mind that all of this is automated through the maven-release-plugin. 如果这听起来像是很多工作,请记住,所有这些都是通过maven-release-plugin实现的。 That means the work is done once, and every release after that is automated. 这意味着工作完成一次,之后的每个版本都是自动化的。 This reduces the likelihood of human error in the release, and accelerates the speed of the release process. 这降低了发布中人为错误的可能性,并加快了发布过程的速度。 It is worth the initial effort to setup. 最初的设置是值得的。

Rebuilding a non-SNAPSHOT number with the "mvn deploy" command is highly discouraged, as it makes the binaries dependent on both the version number and when they were built, where that last bit of information is not tracked. 强烈建议不要使用“mvn deploy”命令重建非SNAPSHOT号码,因为它会使二进制文件依赖于版本号和构建时间,而不会跟踪最后一点信息。

If your version ends with -SNAPSHOT , it is automatically considered as a snapshot by Maven. 如果您的版本以-SNAPSHOT ,则Maven会自动将其视为快照。 Otherwise it is considered as a release version. 否则,它被视为发布版本。

Then, there may be other options, such as testing, debugging, code analysis, but it's quite difficult to know without hands on the project. 然后,可能还有其他选项,例如测试,调试,代码分析,但是如果不亲自动手就很难知道。

[Update] Jenkins seems to do a lot of checkings for the release version as described here: http://labs.bsb.com/2014/02/better-maven-releases-with-jenkins/ [更新] Jenkins似乎对发布版本进行了大量检查,如下所述: http//labs.bsb.com/2014/02/better-maven-releases-with-jenkins/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM