Sub topic 6
Publishing application, build, and git information
This chapter covers the info endpoint. It answers a basic operations question: which version of the application is running on this server? You should already know how to add Actuator and expose endpoints (earlier chapters). You should also be comfortable with Maven or Gradle builds and YAML configuration.
What the info endpoint does
The info endpoint returns a JSON document that describes the application. Unlike health and metrics, its content is not computed from live state. Each part of the document comes from an InfoContributor, a bean that adds a section to the result. Spring Boot ships several contributors, and you can write your own.
Typical uses:
- Confirm during a deployment that the new version is the one serving traffic.
- Trace a bug report to an exact commit.
- Let a dashboard or a smoke test read the version without parsing logs.
The endpoint is at /actuator/info. Only health is exposed over HTTP by default, so add info to the exposure list:
management:
endpoints:
web:
exposure:
include: health,infoHow the pieces fit together
Each contributor reads from a different source. The endpoint merges their output into one document.
The build and git contributors depend on files created at build time. If the build does not create the file, that section is silently missing. This is the most common reason for an info response that looks empty.
Static values from properties
The environment contributor copies every property that starts with info. into the response. Since Spring Boot 2.6 it is off by default, so you must enable it:
management:
info:
env:
enabled: true
info:
app:
name: Order Service
team: paymentsThe response contains:
{
"app": {
"name": "Order Service",
"team": "payments"
}
}If you use spring-boot-starter-parent with Maven, you can fill values from the POM through resource filtering. The @...@ placeholder syntax is used because the parent POM changes the default ${...} delimiter. In YAML you must quote the value, because @ is a reserved character at the start of a scalar:
info:
app:
version: "@project.version@"Use this for values you set by hand. For version and commit data, prefer the generated files below, because they cannot drift from the real build.
Build information
The build contributor reads META-INF/build-info.properties from the classpath. You generate that file with the Spring Boot build plugin.
For Maven, add the build-info goal to the plugin:
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>build-info</goal>
</goals>
</execution>
</executions>
</plugin>For Gradle, use the buildInfo() DSL:
springBoot {
buildInfo()
}After a build, /actuator/info includes a section like this:
{
"build": {
"artifact": "order-service",
"group": "com.example",
"name": "order-service",
"version": "1.4.2",
"time": "2026-12-01T08:41:07.512Z"
}
}Two details matter in practice:
- The
timevalue changes on every build. This makes builds non-reproducible, which can break caching or artifact comparison. The Maven plugin supports aproject.build.outputTimestampproperty that fixes the value. Gradle lets you setbuildInfo { properties { time = null } }to omit it. - You can add your own keys, such as a CI build number, with the plugin's
additionalPropertiessetting. They appear underbuild.
Git information
The git contributor reads a git.properties file. You generate it with the git-commit-id plugin. With Maven and spring-boot-starter-parent, the plugin version and a sensible configuration are already managed, so you only declare the plugin:
<plugin>
<groupId>io.github.git-commit-id</groupId>
<artifactId>git-commit-id-maven-plugin</artifactId>
</plugin>If your project does not inherit from the Boot parent, you must configure the plugin yourself and set generateGitPropertiesFile to true. For Gradle, apply the com.gorylenko.gradle-git-properties plugin (now published as com.gradleup.git-properties).
By default the response shows the branch, the abbreviated commit ID, and the commit time:
{
"git": {
"branch": "main",
"commit": {
"id": "a1b2c3d",
"time": "2026-12-01T08:30:12Z"
}
}
}To include the full commit message, author, and remote URL, set the mode to full:
management:
info:
git:
mode: fullChecking the build output
The files must end up inside the packaged application. Verify this before debugging the endpoint:
mvn -q package
unzip -l target/order-service-1.4.2.jar | grep -E "build-info|git.properties"For a Spring Boot executable jar, both files appear under BOOT-INF/classes. If a file is missing, the plugin did not run, or the build was done without a .git directory (common in some CI checkouts and Docker builds that do not copy it).
Other built-in contributors
Spring Boot 3.2 and later add contributors for runtime details. Each is off by default:
| Property | Adds |
|---|---|
| `management.info.java.enabled` | Java vendor, version, and runtime details |
| `management.info.os.enabled` | Operating system name, version, and architecture |
| `management.info.process.enabled` | Process ID, parent process ID, and available processors |
management:
info:
java:
enabled: true
os:
enabled: true
process:
enabled: trueThese help when you suspect that a node runs a different JDK than the others.
Writing a custom contributor
When none of the built-in sources fit, implement InfoContributor. Spring Boot collects all such beans and calls them on each request.
import java.lang.management.ManagementFactory;
import java.time.Instant;
import java.util.Map;
import org.springframework.boot.actuate.info.Info;
import org.springframework.boot.actuate.info.InfoContributor;
import org.springframework.stereotype.Component;
@Component
public class RuntimeInfoContributor implements InfoContributor {
@Override
public void contribute(Info.Builder builder) {
long startMillis = ManagementFactory.getRuntimeMXBean().getStartTime();
builder.withDetail("runtime", Map.of(
"startedAt", Instant.ofEpochMilli(startMillis).toString(),
"processors", Runtime.getRuntime().availableProcessors()));
}
}The response gains a runtime object next to the other sections. The key you pass to withDetail becomes the top-level name, so choose one that does not clash with app, build, or git.
Common problems
- The response is
{}. No contributor produced data. Check thatinfo.*properties exist andmanagement.info.env.enabledistrue, and that the build files are present in the jar. - The endpoint returns 404.
infois not inmanagement.endpoints.web.exposure.include. - The git section is missing in CI. The build ran without the
.gitdirectory. Fetch the repository properly, or fail the build when the plugin finds no repository by setting itsfailOnNoGitDirectoryoption totrue. - The version shows as
@project.version@. Resource filtering is not active. This happens when the project does not inherit fromspring-boot-starter-parentand filtering is not enabled forapplication.yml. - Values look stale after a change. The contributors read the generated files at startup in most cases, so restart the application after rebuilding.
Exercise
Your team deploys the application and then calls /actuator/info. The response is {"app":{"name":"Order Service"}}, with no build or git sections, although info is exposed and the application runs from a packaged jar. Name two likely causes and how you would confirm each one.
Show answer
The build did not generate META-INF/build-info.properties, because the build-info goal is not configured, or git.properties, because the git-commit-id plugin is missing or the build ran without a .git directory. Confirm by listing the jar contents with unzip -l target/<name>.jar | grep -E "build-info|git.properties". If a file is absent, add the plugin or goal, or give the CI job access to the repository history, then rebuild and redeploy.
Exercise
Why should you prefer build-info and git.properties over a hand-written info.app.version property for reporting the running version?
Show answer
The generated files are produced by the build from the real project version and the real commit, so they cannot disagree with the artifact being deployed. A hand-written property must be updated manually and can be forgotten, which makes the endpoint report a version that does not match the running code.