简体   繁体   English

Maven版本控制和发布GIT存储库

[英]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. 我在单个GIT存储库中有多个maven项目。我想为maven项目执行单独的发布,将发布版本推到nexus,跳过标记并增加快照并提交。

Maven release goal used 使用的Maven发布目标

release:clean release:prepare release:perform

Maven Release plugin : Maven Release插件:

<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. 由于标记发生在存储库中,因此我想跳过GIT中的标记。我们将在代码冻结窗口期间手动进行标记。

I would to avoid creating individual repository for the maven projects. 我要避免为Maven项目创建单独的存储库。

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: 我认为Maven和Nexus可以使用的最佳(最简单,最可靠)方法是:

  • Use SNAPSHOT repository. 使用SNAPSHOT存储库。 When uploading to Nexus by default SNAPSHOT is replaced with a resolved snapshot version - it contains a timestamp and an incremental number. 默认情况下,当上传到Nexus时,SNAPSHOT会替换为解析的快照版本-它包含时间戳记和增量编号。 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. 将此版本放在可见的位置(例如,Jenkins Build的描述),并在部署期间将其复制粘贴。
  • 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. 例如,您可以在Nexus中配置任务以删除非常旧的快照以释放空间。
  • Doesn't depend on how you manage VCS repositories 不取决于您如何管理VCS储存库

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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