Search code examples
mavenjenkinsjenkins-pluginsrelease-managementmaven-release-plugin

Jenkins Maven Release: Replace Snapshot Dependencies


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)?


Solution

  • 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.