简体   繁体   中英

Maven versioning and release GIT repository

I have a multiple maven projects in a single GIT repository .I wanted to perform individual release for the maven projects,push the release version to nexus, skip the tagging and increment the snapshot and commit.

Maven release goal used

release:clean release:prepare release:perform

Maven Release plugin :

<plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-release-plugin</artifactId>
                    <version>${maven.releaseplugin.version}</version>
                    <configuration>
                        <tagNameFormat>v@{project.version}</tagNameFormat>
                        <autoVersionSubmodules>true</autoVersionSubmodules>
                        <releaseProfiles>releases</releaseProfiles>
                    </configuration>
                </plugin>

Since the tagging happens to a repository i wanted to skip the tagging in GIT.We will do the tagging manually during code freeze window.

I would to avoid creating individual repository for the maven projects.

Can you please tell me how can i acheive it in better way.

I would also like to understand how it is managed in other companies.

The best (easiest and robust) way that I think is available with Maven & Nexus is:

  • Use SNAPSHOT repository. When uploading to Nexus by default SNAPSHOT is replaced with a resolved snapshot version - it contains a timestamp and an incremental number. You can build and set this version yourself:
 VERSION=`mvn help:evaluate -Dexpression=project.version | grep -v "^\\["| grep -v Download` VERSION=${VERSION/%-SNAPSHOT/} #get rid of -SNAPSHOT if it's there VERSION="$VERSION-"`date +"%Y%m%d.%H%M%S"`"-$BUILD_NUMBER" mvn versions:set -DnewVersion=$VERSION 
  • Put this version into some visible place (eg Description of Jenkins Build) and copy-paste it during deployments.
  • Because you know the version you can pass it to the next job building Deployment Pipelines with automated deployments.

Pros:

  • No tagging, no release versions (they are not compatible with Continuous Delivery)
  • Very easy and almost no custom scripting
  • Using capabilities of the existing tools. Eg you can configure tasks in Nexus to delete very old snapshots to free up space.
  • Doesn't depend on how you manage VCS repositories

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM