I'd like the /info
actuator endpoint from my Spring Boot (1.2.4.RELEASE) application to return the version as specified in the build.gradle
file.
In my build.gradle
file I have a line as so:
version = '0.0.1-SNAPSHOT'
I am using yaml configuration file. Right now I have the version duplicated as so in application.yml
:
info:
build:
version: 0.0.1-SNAPSHOT
Is this possible?
Add the following to the build.gradle
file. It is not necessary to create an InfoContributor
class.
plugins {
id 'org.springframework.boot' version '<version>'
}
springBoot {
buildInfo()
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-actuator'
etc...
}
Query http://host:port/actuator/info
and you will see something like...
{
"build": {
"artifact": "spring-example",
"name": "spring-example",
"time": "2020-01-30T09:47:33.551Z",
"version": "0.0.1-SNAPSHOT",
"group": "com.example"
}
}
N.b. Tested with 2.2.4.RELEASE
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With