I am using the mvn-release-plugin in batch mode to release the artifacts to both production and lower environments. I would like the lower environments to always and push and pull from the Artifactory Snapshots repository.
By default, mvn-release-plugin removes the SNAPSHOT suffix before rolling out the artifacts (pom/jar) to the repository. I would like to tweak with behavior and actually retain the SNAPSHOT suffix for build artifacts when releasing to Artifactory Snapshots repository. Is this possible without custom scripting ?
Well, typically release pipeline looks like:
where:
release:prepareis responsible for bumping project version twice (snapshot -> releaseandrelease -> snapshot), verifying that it is possible to build release version (via preparationGoals configuration), committing corresponding changes to SCM and storing information about release version inrelease.propertiesfilerelease:performis responsible for checking out release version from SCM and deploying release artifacts (via goals configuration)Now, our goal is to somehow influence on release pipeline to force it to deploy snapshot artifacts as well and skip(?) deploying release artifacts. The solution actually depends on what snapshot versions we are going to deploy: current or upcoming.
In case of deploying current version, everything should actually be pretty straightforward - just adding
deploylifecycle phase beforemaven-release-plugingoals and skippingrelease:performshould work:however, it doesn't - in my case I'm getting NPE in
AbstractRewritePomsPhase#rewriteParentmethod, it looks like goals/steps performed bydeploylifecycle phase change maven session state which in turn preventsrelease:preparegoal from running smoothly. I do see two options there:mvncommands, i.e.:and issue something like (however, in that case maven won't prompt you for specifying release and development versions - extra setup is required):
The same applies for deploying upcoming snapshot version - we just need to swap
release:clean release:prepareanddeploygoals/phases, i.e. either:or