Question

In one of our maven projects, we have a dependency to a Commons-POM, which is also used by other projects and therefore not part of the Parent-POM. Since it is also under development we refer to the SNAPSHOT version.

When creating a release with Jenkins, it will use the snapshot dependency. But what we want is to use the latest release or simply replace the snapshot with the release version.

So is it possible in Jenkins to replace the snapshot versions? Maybe the same way, Maven Release plugin does it when performing manually (it prompts for resolving the dependencies)?

Was it helpful?

Solution 2

Maybe it's possible with not hardcoding the version but having a parameter (<version>${dependency.version}</version>) and then starting the build with mvn clean install -Ddependecy.version=VERSION (in Jenkins you can parametrize builds). But this is nothing more than a hack!

Having SNAPSHOT dependencies during development is ok (and sometimes a pain ;-) but before releasing your project you should release the dependency.

If the development of the commons project is (currently) tightly coupled to your project you could consider having the commons project in the same release cycle like your project for the time being.

OTHER TIPS

The Versions Maven Plugin offers the goal versions:use-latest-releases. You can use this goal in a pre-step maven call prior to your your regular build like this:

versions:use-latest-releases -Dincludes=com.yourcompany.yourgroupid:yourartifactid versions:commit scm:checkin

That way, you can keep the SNAPSHOT dependency until the artifact is actually released.

The M2 Release plugin is a Jenkins wrapper around the standard Maven release plugin.

I have the same issue and got some mileage out of the following solution. In Maven Non-Interactive releases, at the bottom of the page it describes using a releases.properties file to define the versions.

Rather than hand cranking this file, I first ran maven locally using:

mvn -U release:prepare -DdryRun=true -Dresume=false

After answering all the questions, it creates the releases.properties file you would like to use. The only thing that needs to be done is to edit the release.properties file.

At the end of the file is:

completedPhase=end-release

change this to:

completedPhase=check-dependency-snapshots

see: Maven Release Plugin phases This will have the effect of short circuiting the scm-check-modifications but you are on a build server, so there should be no local modifications.

I checked this file in to our scm at the root of the project (same level as the pom)

On jenkins, I then have these settings for release:

--batch-mode release:prepare release:perform

It seems a bit messy to me. I am hopeful there is a cleaner way. [Running: Jenkins 1.533, Jenkins Maven Release Plug-in Plug-in 0.12.0, Maven Integration plugin 1.533]

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top