springboot~关于打包时记录当前git信息

当在Maven项目中遇到打包发布后自己的提交未生效的问题,可以使用git-commit-id-plugin插件。该插件生成git.properties文件,记录Git的提交详情,帮助开发者验证是否包含最新提交。在父项目配置此插件,可确保所有子项目具备此功能。
摘要由CSDN通过智能技术生成

Maven打包发布版本可能会遇到自己的提交不起作用的情况,排查比较困难,可能需要拉下服务器上包,反编译查看是否包含自己的提交记录。如果使用的是GIT作为SCM,可以使用 git-commit-id-plugin插件
该插件在打包时生产一个git.properties文件,里面记录本次git提交的信息。

#Generated by Git-Commit-Id-Plugin
git.build.time=2022-07-28 09\:15\:53
git.build.version=1.0.0
git.commit.id=dc8103b5cf9d51d59169e0682e9990456a72f231
git.commit.id.abbrev=dc8103b
git.commit.id.describe=dc8103b-dirty
git.commit.id.describe-short=dc8103b-dirty
git.commit.message.full=update cache log
git.commit.message.short=update cache log
git.commit.time=2022-07-28 08\:58\:43
  • 可以在父项目中添加这个插件,这样子项目也就具有了这个能力
  <!--打包jar 与git commit 关联插件-->
<plugin>
    <groupId>io.github.git-commit-id</groupId>
    <artifactId>git-commit-id-maven-plugin</artifactId>
    <version>${git.commit.plugin}</version>
    <executions>
        <execution>
            <id>get-the-git-infos</id>
            <goals>
                <goal>revision</goal>
            </goals>
            <phase>initialize</phase>
        </execution>
    </executions>
    <configuration>
        <failOnNoGitDirectory>false</failOnNoGitDirectory>
        <generateGitPropertiesFile>true</generateGitPropertiesFile>
        <!--因为项目定制了jackson的日期时间序列化/反序列化格式,因此这里要进行配置,不然通过management.info.git.mode=full进行完整git信息监控时会存在问题-->
        <dateFormat>yyyy-MM-dd HH:mm:ss</dateFormat>
        <includeOnlyProperties>
            <includeOnlyProperty>^git.build.(time|version)$</includeOnlyProperty>
            <includeOnlyProperty>^git.commit.(id|message|time).*$</includeOnlyProperty>
        </includeOnlyProperties>
    </configuration>
</plugin>

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

野生的狒狒

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值