Jenkins Maven Release: Replace Snapshot Dependencies

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

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

So is it possible in Jenkins to replace the version of the images? Perhaps in the same way, the Maven Release plugin does this when executed manually (it asks for dependency resolution)?

+4
source share
4 answers

Perhaps this is possible with a hard-coded version, but with the parameter (<version> $ {dependency.version} </version>), and then start the build using mvn clean install -Ddependecy.version = VERSION (in Jenkins you can parameterize assembly). But this is nothing more than a hack!

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

If the development of the commons project (currently) is closely related to your project, you might consider putting the community project in the same release cycle as your project for now.

+2
source

Versions Maven Plugin offers a purpose version: consuming latest releases . You can use this target in a maven pre-call before your regular build as follows:

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

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

+3
source

M2 Release Plugin - Jenkins wrapper around the standard Maven release plugin .

+1
source

I have the same problem and got the mileage from the following solution. The Maven Non-Interactive releases at the bottom of the page describe how to use the release.properties file for versioning.

Instead of manually cranking this file, I first ran maven locally using:

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

Answering all the questions, he creates the release.properties file that you would like to use. The only thing to do is edit the release.properties file.

At the end of the file is:

 completedPhase=end-release 

change this to:

 completedPhase=check-dependency-snapshots 

see Phases of the Maven Release plugin This will lead to a short circuit of the scm-check changes, but you are on the build server, so there should be no local changes.

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

In jenkins, I have the following settings for release:

 --batch-mode release:prepare release:perform 

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

+1
source

Source: https://habr.com/ru/post/1495276/


All Articles