简体   繁体   中英

How to set maven options to run for release or snapshot

I am using a Jenkins server as CI. I am using a maven docker to run the maven tasks. So here is my problem and my doubts.

With jenkins I use the maven plugin to configure and compile the maven tasks. 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.

But with docker is more complicated because I have to use arguments for the mvn command. 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.

I am using docker.io/maven image.

Maven handles releases and snapshots based on the version number, not based on the command line arguments.

There is a maven-release-plugin that will automate the work required to release a build; 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). Then you would check in the "next" -SNAPSHOT version, and everyone would continue developing on the next snapshot version.

If this sounds like a lot of work, keep in mind that all of this is automated through the 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.

If your version ends with -SNAPSHOT , it is automatically considered as a snapshot by 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/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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