I have configured a Jenkins job to release my maven project automatically. This is done by using the following: mvn --batch-mode clean release:prepare release:perform
You can use a custom groovy script to automatically provide maven-release-plugin with the releaseVersion and developmentVersion. Then the maven command would look somwthing like:
mvn clean release:clean release:prepare release:perform -DreleaseVersion=${releaseVersion} -DdevelopmentVersion=${developmentVersion}
Follow the steps in this answer and change the part of the groovy script to suite your use-cases (for example this part):
def newFixVersion = 0;
if (hasSnapshotPart) {
newMinorRelVersion = minorVersion;
newMinorDevVersion = minorVersion + 1;
} else {
//TODO: either throw an exception here or change the newMinorRelVersion newMinorDevVersion appropriately to suite your use-cases:
//throw new IllegalArgumentException("The pom at location " + POM_LOCATION + " contains the version " + projectVersion + " which is not a snapshot version (missing " + SNAPSHOT_PART + "). This is a released version and nothing should happen to it!");
}