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


    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>
    
  • 相关阅读:
    三连击
    铺地毯
    超级玛丽游戏
    A+B problem
    怎么感觉欠缺点什么、灵光在哪,让我顿悟下
    2016年10月,人生的转折点。
    python第七天
    python第六天
    汉诺塔问题(Hanoi Tower)递归算法解析(Python实现)
    计算多数的乘积(Python实现)
  • 原文地址:https://www.cnblogs.com/lori/p/16527355.html
Copyright © 2020-2023  润新知