Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 502
Robert Avatar asked Aug 14 '15 17:08

Robert


People also ask

How do I run a Maven release?

Performing a release runs the following release phases by default: Checkout from an SCM URL with optional tag to workingDirectory ( target/checkout by default) Run the perform Maven goals to release the project (by default, deploy site-deploy ), eventually with release profile(s) active.

What is the difference between snapshot and release in Maven?

A Maven snapshot is a special version of a Maven package that refers to the latest production branch code. It is a development version that precedes the final release version. You can identify a snapshot version of a Maven package by the suffix SNAPSHOT that is appended to the package version.

Why is it best practice not to release snapshot?

Rule #3 Never release using the Time-Stamped snapshot The release plugin will still fail if you do this because it correctly understands you have SNAPSHOT dependencies. The plugin has a flag to allow bypass this check and people unfortunately use it far too often.

Does Maven plugin allows for release of Maven projects?

This plugin is used to release a project with Maven, saving a lot of repetitive, manual work. Releasing a project is made in two steps: prepare and perform. Note: Maven 3 users are encouraged to use at least Maven-3.0.


1 Answers

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.

like image 179
Edwin Buck Avatar answered Oct 29 '22 04:10

Edwin Buck