LoginSignup
4
6

More than 5 years have passed since last update.

SpringBootでリリースモジュールのGit情報を表示する

Last updated at Posted at 2016-04-19

概要

  • SpingBootでリリースしたWEBアプリのバージョンを表示させる
    • Gitの情報を表示するEndpointを作成する
  • EndpointはSpringBootのActuatorを使い、http://host名/infoにアクセスすることでjsonで取得できるようにする
  • Gradleで実施

手順

build.gradleを設定

  • build.gradleにgradle-git-propertiesを設定
  • build.gradleにSpring Actuatorを設定
build.gradle(抜粋)

buildscript {
    repositories {
      mavenCentral()
      maven {
        url "https://plugins.gradle.org/m2/"
      }
    }
    dependencies {
      classpath "gradle.plugin.com.gorylenko.gradle-git-properties:gradle-git-properties:1.4.16"
    }

}

apply plugin: 'com.gorylenko.gradle-git-properties'

...

dependencies {

...

    compile "org.springframework.boot:spring-boot-starter-actuator"

...

}

gradleでビルド

gradle build
  • ビルド時に自動的にgit-propertiesを作成するtaskが実行される

確認

  • ビルドでできたjarを実行しブラウザからアクセス
  • http://localhost:8080/infoのように/infoから取得できる

  • 実行結果イメージ
    image

4
6
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
6