Maven版本控制和发布GIT存储库 [英] Maven versioning and release GIT repository

查看:196
本文介绍了Maven版本控制和发布GIT存储库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在一个GIT存储库中有多个maven项目.我想为maven项目执行单独的发布,将发布版本推到nexus,跳过标记并增加快照并提交.

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发布目标

Maven release goal used

release:clean release:prepare release:perform

Maven Release插件:

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>

由于标记发生在存储库中,所以我想跳过GIT中的标记.我们将在代码冻结窗口期间手动进行标记.

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.

我会避免为Maven项目创建单独的存储库.

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.

推荐答案

我认为Maven&可以使用的最佳方式(最简单,最可靠). Nexus是:

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

  • 使用SNAPSHOT存储库.默认情况下,当上传到Nexus时,SNAPSHOT会替换为解析的快照版本-它包含时间戳记和增量编号.您可以自己构建和设置此版本:
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

  • 将此版本放置到可见的位置(例如,Jenkins Build的描述),并在部署期间将其复制粘贴.
  • 因为您知道版本,您可以将其传递给具有自动部署功能的下一个构建部署管道"的工作.
  • 优点:

    • 没有标签,没有发行版本(它们与持续交付不兼容)
    • 非常容易,几乎没有自定义脚本
    • 使用现有工具的功能.例如.您可以在Nexus中配置任务以删除非常旧的快照以释放空间.
    • 不取决于您如何管理VCS存储库

    这篇关于Maven版本控制和发布GIT存储库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆