When accessing my Spring Actuator /info
endpoint I receive the following information:
{
"git": {
"branch": "8743b52063cd84097a65d1633f5c74f5",
"commit": {
"id": "b3j2924",
"time": "05.07.2021 @ 10:00:00 UTC"
}
},
"build": {
"encoding": {
"source": "UTF-8"
},
"version": "1.0",
"artifact": "my-artifact",
"name": "my-app",
"time": 0451570333.122000000,
"group": "my.group"
}
}
My project does not maintain a META-INF/build-info.properties
file.
I now wanted to write a unit-test for that exact output but get the following error:
java.lang.AssertionError:
Expecting actual:
"{"git":{"branch":"8743b52063cd84097a65d1633f5c74f5","commit":{"id":"b3j2924","time":"05.07.2021 @ 10:00:00 UTC"}}}"
to contain:
"build"
The whole build
block is missing in the output.
My questions are the following:
- What needs to be done to access the build information during a local unit-test run without providing a
META-INF/build-info.properties
. - From where does Spring Actuator retrieve the actual build information when my project does not has a
META-INF/build-info.properties
file so it gives me the output from above?
CodePudding user response:
The build-info.properties file is typically generated at build time by Spring Boot's Maven or Gradle plugins.