Maven versioning and release GIT repository

柔情痞子 提交于 2020-05-16 03:23:06

问题


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.


回答1:


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 (e.g. 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. E.g. you can configure tasks in Nexus to delete very old snapshots to free up space.
  • Doesn't depend on how you manage VCS repositories


来源:https://stackoverflow.com/questions/48267985/maven-versioning-and-release-git-repository

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!