亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

git驗(yàn)證線上的版本是否符合預(yù)期

 更新時間:2022年07月23日 11:58:15   作者:Linyb極客之路  
當(dāng)我們想知道部署項(xiàng)目的哪個版本有問題?當(dāng)我們想知道線上運(yùn)行的版本是否是我們預(yù)期的版本?當(dāng)我們想把部署的版本與代碼進(jìn)行關(guān)聯(lián)?如果是你用git來做版本管理,那就可以使用git-commit-id-maven-plugin插件來實(shí)現(xiàn)上述功能

正文

git-commit-id-maven-plugin插件,會根據(jù)當(dāng)前分支的版本號生成一個git.properties文件。

git.properties內(nèi)容形如下

git.branch=master
git.build.host=xxx
git.build.time=2022-03-01T20\:33\:43+0800
git.build.user.email=aaa@qq.com
git.build.user.name=aaa
git.build.version=1.0-SNAPSHOT
git.closest.tag.commit.count=
git.closest.tag.name=
git.commit.id=6dab4430864e3e4a9fc1ba6f6b93f278100d4e2e
git.commit.id.abbrev=6dab443
git.commit.id.describe=6dab443-dirty
git.commit.id.describe-short=6dab443-dirty
git.commit.message.full=Add README.md
git.commit.message.short=Add README.md
git.commit.time=2022-03-01T16\:24\:48+0800
git.commit.user.email=aa@example
git.commit.user.name=aa
git.dirty=true
git.remote.origin.url=http://hello
git.tags=
git.total.commit.count=1

如何使用

本文以springboot項(xiàng)目為例,springboot項(xiàng)目的parent pom里面已經(jīng)內(nèi)嵌git-commit-id-maven-plugin插件管理依賴。如下

<pluginManagement>
?<plugins>
????<plugin>
??????????<groupId>pl.project13.maven</groupId>
??????????<artifactId>git-commit-id-plugin</artifactId>
??????????<executions>
????????????<execution>
??????????????<goals>
????????????????<goal>revision</goal>
??????????????</goals>
????????????</execution>
??????????</executions>
??????????<configuration>
????????????<verbose>true</verbose>
????????????<dateFormat>yyyy-MM-dd'T'HH:mm:ssZ</dateFormat>
????????????<generateGitPropertiesFile>true</generateGitPropertiesFile>
????????????<generateGitPropertiesFilename>${project.build.outputDirectory}/git.properties</generateGitPropertiesFilename>
??????????</configuration>
????????</plugin>
???</plugins>
</pluginManagement>

項(xiàng)目中做如下配置

1、在我們的項(xiàng)目中顯式引入git-commit-id-plugin插件

<build>
????????<plugins>
????????????<plugin>
????????????????<groupId>pl.project13.maven</groupId>
????????????????<artifactId>git-commit-id-plugin</artifactId>
????????????</plugin>
????????</plugins>
?</build>

2、通過和actuator集成,顯示git信息

a、在項(xiàng)目中引入actuator GAV

<dependency>
????????????<groupId>org.springframework.boot</groupId>
????????????<artifactId>spring-boot-starter-actuator</artifactId>
????????</dependency>

b、瀏覽器訪問http://ip : port/actuator/info


如果覺得上面的信息不夠多,我們可以通過自定義端點(diǎn)或者自己寫一個controller把信息展示出來

詳細(xì)的信息可以通過org.springframework.boot.info.GitProperties展示

本示例以自定義端點(diǎn)為例。示例如下

@Endpoint(id =?"git")
@Component
public?class?GitEndpoint?{
????@Autowired(required =?false)
????private?GitProperties gitProperties;
????@ReadOperation
????public?Object?info()?throws?IOException?{
????????if(ObjectUtils.isEmpty(gitProperties)){
????????????return?new?HashMap<>();
????????}
????????return?gitProperties;
????}
}

在application.yml中開放自定義端點(diǎn)

management:
??endpoints:
????web:
??????exposure:
????????include:?'git'

瀏覽器訪問http://ip : port/actuator/git


如果仍然覺得上述的信息還是不夠詳細(xì),那可以通過解析git.properties文件顯示。示例

@Endpoint(id =?"gitDetail")
@Slf4j
@Component
public?class?GitDetailEndPoint?{
????@ReadOperation
????public?Object?detail()?throws?IOException?{
????????Properties props =?null;
????????try?{
????????????props = PropertiesLoaderUtils.loadAllProperties("git.properties");
????????????return?props;
????????}?catch?(IOException e) {
????????????log.error("git.properties not found");
????????}?finally?{
????????}
????????return?new?HashMap<>();
????}
}

在application.yml中開放自定義端點(diǎn)

management:
??endpoints:
????web:
??????exposure:
????????include:?'gitDetail'

瀏覽器訪問http://ip:port/actuator/gitDetail

總結(jié)

git-commit-id-maven-plugin在分布式或者微服務(wù)項(xiàng)目中,用來驗(yàn)證項(xiàng)目版本還是挺有用的,推薦大家有機(jī)會用一下

demo鏈接

以上就是git驗(yàn)證線上的版本是否符合預(yù)期的詳細(xì)內(nèi)容,更多關(guān)于git驗(yàn)證線上版本的資料請關(guān)注腳本之家其它相關(guān)文章!

相關(guān)文章

  • 詳解git基本操作和指令

    詳解git基本操作和指令

    這篇文章主要介紹了git基本操作和指令的相關(guān)知識,本文給大家介紹的非常詳細(xì),對大家的學(xué)習(xí)或工作具有一定的參考借鑒價值,需要的朋友參考下吧
    2020-11-11
  • String與string的區(qū)別(注意大小寫)

    String與string的區(qū)別(注意大小寫)

    String與string的區(qū)別(注意大小寫)
    2010-06-06
  • 各類常見語言清除網(wǎng)頁緩存方法匯總

    各類常見語言清除網(wǎng)頁緩存方法匯總

    這篇文章主要介紹了各類常見語言清除網(wǎng)頁緩存方法匯總,包括了常見的html、asp、php與java,非常具有實(shí)用價值,需要的朋友可以參考下
    2014-10-10
  • Git本地倉庫基本操作及技巧

    Git本地倉庫基本操作及技巧

    這篇文章主要介紹了Git本地倉庫基本操作及一些小技巧,本文給大家介紹的非常詳細(xì),對大家的學(xué)習(xí)或工作具有一定的參考借鑒價值,需要的朋友可以參考下
    2020-08-08
  • 目標(biāo)檢測mAP的概念及公式詳解

    目標(biāo)檢測mAP的概念及公式詳解

    這篇文章主要為大家介紹了我們在進(jìn)行目標(biāo)檢測時需要用到的mAP概念及公式詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2022-05-05
  • 遇到不能復(fù)制的網(wǎng)站怎么辦?

    遇到不能復(fù)制的網(wǎng)站怎么辦?

    有時我們看到喜歡的網(wǎng)頁內(nèi)容時定會產(chǎn)生復(fù)制下來為我所用的沖動,不過當(dāng)你點(diǎn)擊鼠標(biāo)時它卻沒有任何反應(yīng),選擇的內(nèi)容沒有任何變化,不禁有點(diǎn)掃興。不要緊,辦法總比困難多!
    2009-06-06
  • Unity開發(fā)VR項(xiàng)目問題總結(jié)分析

    Unity開發(fā)VR項(xiàng)目問題總結(jié)分析

    本篇文章主要對Unity開發(fā)VR項(xiàng)目會遇到的一些問題總結(jié),針對這些問題進(jìn)行分析解決,有需要的朋友可以借鑒參考下,希望對大家有所幫助
    2021-09-09
  • 自定義?Github?Action?庫實(shí)戰(zhàn)詳解

    自定義?Github?Action?庫實(shí)戰(zhàn)詳解

    這篇文章主要為大家介紹了自定義?Github?Action?庫實(shí)戰(zhàn)詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2022-09-09
  • kali添加開機(jī)自啟的方法

    kali添加開機(jī)自啟的方法

    采用systemd的方法,kali默認(rèn)是沒有rc.local的,需要自己創(chuàng)建。本方法也適用于ubuntu 18.04 64bit,對kali添加開機(jī)自啟知識感興趣的朋友一起看看吧
    2022-09-09
  • 文章中優(yōu)酷視頻全屏及去除廣告在線轉(zhuǎn)換

    文章中優(yōu)酷視頻全屏及去除廣告在線轉(zhuǎn)換

    很多網(wǎng)站發(fā)表了引用優(yōu)酷視頻不能全屏,或一點(diǎn)全屏又跳到官方網(wǎng)了,結(jié)果又要重新緩沖。用戶體驗(yàn)特別不好。
    2010-09-09

最新評論