Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Spring Boot 2.0 Actuator git properties not added to /info

I'm using Gradle with Spring Boot 2.0.0.M7 and have the following plugins applied:

buildscript {
    repositories {
        maven { url "https://plugins.gradle.org/m2/" }
        maven { url "https://repo.spring.io/milestone" }
    }
    dependencies {
        classpath "org.springframework.boot:spring-boot-gradle-plugin:2.0.0.M7"
    }
}

plugins {
    id "com.gorylenko.gradle-git-properties" version "1.4.17"
}

spring-boot-starter-actuator dependency is also there. git.properties files is generated correctly to build/main/resoures directory. I've also added property management.info.git.mode=full. Due to official docs, git information should be added to /info endpoint automatically with GitInfoContributor. However none of the above helps and /info endpoint returns empty JSON instead - {}. Any ideas on how this can be fixed?

UPDATE 1: What I've found so far is that if I manually copy git.properties to out/resources, this way it would work, but they are not put there for some reason.

UPDATE 2: When I run with gradle bootRun it works, however when I start it from Intellij IDEA our run gradle clean build which runs the test which checks if those properties are displayed on /info endpoint - it doesn't work.

like image 898
Yuriy Yunikov Avatar asked Jan 07 '18 00:01

Yuriy Yunikov


3 Answers

The problem was running the app from IDE. As the properties are generated on the phase when JAR is assembled, they were not included. Running the application via java -jar artifact.jar or gradle bootRun works without any issues.

Thanks @fateddy for help on resolving the issue.

like image 150
Yuriy Yunikov Avatar answered Nov 14 '22 07:11

Yuriy Yunikov


You can configure your IDE to call the process-resources maven goal, prior to the Build/Launch, this will cause the git.properties file and build-info.properties files to be generated prior to the application launching.

I use Maven, but a similar configuration should be possible for Gradle.

IntelliJ Build/Run Configuration

like image 22
eztinkerdreams Avatar answered Nov 14 '22 09:11

eztinkerdreams


For IntelliJ IDEA, you can enable Delegate IDE build/run actions to Gradle option in Settings (Preferences) | Build, Execution, Deployment | Build Tools | Gradle | Runner tab.

like image 3
user2749103 Avatar answered Nov 14 '22 08:11

user2749103