Search code examples
spring-bootgradlespring-boot-actuator

Spring Boot build information via /info actuator endpoint


In a Spring Boot application, I would like to get the build and other application related information in /info actuator endpoint via buildInfo() from springBoot plugin task. However, the build information properties file name is not build-info.properties rather it's different {app_name}.properties. The property file exists in /META-INF/{app_name}.properties in the spring boot created fat jar.

springBoot {
    buildInfo()
}

My question is: Is there any way the property file name can be configured in the task rather than taking default?

Update:

enter image description here


Solution

  • You misinterpret how buildInfo works. actuator endpoint uses build-info.properties file from /META-INF/. buildInfo configuration does not work in runtime, actually there is no gradle at runtime (that is when your application runs for example on production).

    buildInfo() adds a task to you gradle build that can generate build-info.properties based on properties in {app_name}.properties file during build of your application. Given that you already has it you need to run it during the build as described in documentation:

    This will configure a BuildInfo task named bootBuildInfo and, if it exists, make the Java plugin’s classes task depend upon it