Scrivio Interview library
CodingFoundations6 min read · updated 12 November 2026

How do you show the build version and git commit in /actuator/info?

We generate two small files during the build: META-INF/build-info.properties, with the spring-boot-maven-plugin's build-info goal or springBoot { buildInfo() } in Gradle, and git.properties, with a git commit id plugin. Spring Boot finds them on the classpath and its build and git info contributors add them to /actuator/info. management.info.git.mode=full shows every git detail instead of the short summary, and if we also want our own info.* properties, we enable the env contributor with management.info.env.enabled=true.

Why this question is asked

When something goes wrong in production, one of the first questions is exactly what code is running. Is it the build from this morning or last week's? Does it contain the fix we merged yesterday? A version string and a commit id in /actuator/info answer that in seconds, and many deployment tools and dashboards read them automatically. Interviewers ask this as a practical check that we know how Spring Boot collects this information and which parts are switched off by default. In this answer, we will recap what the info endpoint shows, generate build info in Maven and Gradle, add git information, look at the full git mode, and add custom info properties.

1A Quick Recap of /actuator/info

The info endpoint returns a JSON document assembled from info contributors, small beans that each add one section. Spring Boot ships several: build adds the content of META-INF/build-info.properties, git adds the content of git.properties, env adds any property whose name starts with info., and there are java, os and process contributors for runtime details. The build and git contributors switch themselves on when their file exists; env, java, os and process are off unless we enable them.

There is one more step before anyone can see it. Over HTTP, Spring Boot only exposes the health endpoint by default, so we add info to the exposure list.

Properties
management.endpoints.web.exposure.include=health,info
# Before adding anything else:
# GET /actuator/info -> 200 {}

An empty object is the normal starting point. It means the endpoint works, but no contributor found anything to show.

2Generating Build Info

Build info is created by the build tool, not at runtime. In Maven, the spring-boot-maven-plugin has a build-info goal that writes META-INF/build-info.properties into the output, using the project's group, artifact, name and version and the build time.

XML
<!-- pom.xml -->
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>build-info</goal>
</goals>
</execution>
</executions>
</plugin>
// build.gradle
springBoot {
buildInfo()
}
# target/classes/META-INF/build-info.properties (generated)
# build.group=com.acme
# build.artifact=orders
# build.name=orders
# build.version=1.4.2
# build.time=2026-11-05T09:12:44.120Z

Once this file is on the classpath, Boot also creates a BuildProperties bean, so our own code can inject it and read getVersion(), which is handy for adding the version to logs or metrics. We can add extra entries through the plugin's additionalProperties configuration, for example a build number from the CI system.

3Adding Git Information

For git details we need a separate plugin that reads the repository at build time and writes git.properties. In Maven, that is the git-commit-id-maven-plugin; when the project uses spring-boot-starter-parent, its plugin management already configures the plugin to produce the file, so we only declare it. In Gradle, the com.gorylenko.gradle-git-properties plugin does the same job.

XML
<!-- pom.xml, with spring-boot-starter-parent -->
<plugin>
<groupId>io.github.git-commit-id</groupId>
<artifactId>git-commit-id-maven-plugin</artifactId>
</plugin>
// build.gradle
plugins {
id 'com.gorylenko.gradle-git-properties' version '2.4.2' // check the current version
}
# GET /actuator/info
{
"git": {
"branch": "main",
"commit": { "id": "3f2a9c1", "time": "2026-11-05T08:57:10Z" }
},
"build": {
"artifact": "orders", "name": "orders", "group": "com.acme",
"version": "1.4.2", "time": "2026-11-05T09:12:44.120Z"
}
}
Step throughHow build and git details reach /actuator/info
  1. Build runs build-info goalwrites META-INF/build-info.properties
  2. Git plugin reads the repositorywrites git.properties
  3. Both files are packaged in the jar
  4. Boot finds them at startupbuild and git info contributors switch on
  5. Is info in the web exposure list?
    YesGET /actuator/info shows themNoEndpoint returns 404

5 steps in order. Play them, or step through them one at a time.

Notice that the git section is short. By default Boot shows only the branch, the abbreviated commit id and the commit time, even though git.properties contains much more. One catch in CI: the build must run in a real git checkout with the history the plugin needs. Some pipelines use shallow clones or copy sources without the .git folder, and then the plugin fails or the file is missing, so check this when the git section does not appear.

4Showing More Git Detail

When we want the full commit id, the commit message, the author or whether the working tree was dirty, we switch the git contributor to full mode.

Properties
management.info.git.mode=full
# GET /actuator/info -> the git section now includes, for example:
# "commit": { "id": { "full": "3f2a9c1e8b...", "abbrev": "3f2a9c1" },
# "message": { "short": "Fix rounding in invoice totals" },
# "user": { "name": "...", "email": "..." } },
# "dirty": "false", "build": { ... }, "remote": { ... }

Full mode is useful but shares more, including author names and emails and the remote URL. That is one more reason to keep the info endpoint behind authentication outside of internal networks.

5Adding Our Own info.* Properties

Teams often want a few extra fields, such as the owning team or the environment. Any property under info. becomes part of the endpoint, but only through the env contributor, which has been disabled by default since Spring Boot 2.6.

Properties
management.info.env.enabled=true
info.team=payments
info.environment=${DEPLOY_ENV:local}
info.app.description=Order service
# GET /actuator/info -> adds
# "team": "payments", "environment": "production",
# "app": { "description": "Order service" }

Without management.info.env.enabled=true, these properties are silently ignored, which is the most common reason someone's info.* values do not appear. If we need computed values, we can write our own InfoContributor bean, which receives an Info.Builder and adds whatever details we want.

6Follow-up questions

How do I read the version in my own code?

Inject BuildProperties, which Boot creates when build-info.properties exists, and call getVersion() or getTime(). For git data, inject GitProperties and call getShortCommitId(). Both beans are absent when the files are missing, so use ObjectProvider if the code must also run without them.

Why not read the version from the jar manifest instead?

That works for the version, through getClass().getPackage().getImplementationVersion(), but it only works when running from a packaged jar and it carries no commit or build time. Build info is consistent in tests and in the IDE once the build has run, and Actuator shows it without code.

Can I make the build time reproducible?

Yes. Reproducible builds need the same output for the same input, and a timestamp breaks that. The build-info goal lets us set the time property to a fixed value or to the project's output timestamp, or to off, so two builds of the same commit produce identical files.

7Conclusion

In this answer, we saw that /actuator/info is built from contributors. Build details come from META-INF/build-info.properties, produced by the build-info goal in Maven or springBoot { buildInfo() } in Gradle, and git details come from git.properties, produced by a git commit id plugin. Boot's build and git contributors pick these up automatically once info is exposed, management.info.git.mode=full shows every git field, and custom info.* properties need management.info.env.enabled=true.

What to say in the interviewAbout 70 seconds aloud

Open with

Spring Boot builds /actuator/info from contributors, and two of them, build and git, switch on automatically when their files are on the classpath. For build info, I add the build-info goal to the spring-boot-maven-plugin, or springBoot { buildInfo() } in Gradle.

Then, if they want more

That writes META-INF/build-info.properties with the group, artifact, name, version and build time, and Boot also exposes it as a BuildProperties bean I can inject. For the commit, I add the git-commit-id-maven-plugin, which the Boot parent already configures, or the gradle-git-properties plugin. It writes git.properties during the build.

Then I make sure info is exposed over HTTP, because by default only health is, with management.endpoints.web.exposure.include=health,info. The endpoint then shows the version and the branch, short commit id and commit time. If I need the full commit id, message and dirty flag, I set management.info.git.mode=full.

And if the team wants custom fields like info.team, I have to enable the env contributor with management.info.env.enabled=true, because it has been off by default since Boot 2.6. In CI I check that the build runs in a real git checkout, otherwise the git file is missing.

About this answer

Last updated
12 November 2026
Versions it names
Spring Boot 2.6
Checked
Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
Where the question comes from
Written by Scrivio for practice. It is not taken from an interview.
Official documentation
Spring Boot reference, Actuator
Report an issue with this answer

Copy the line below and send it to the author with what you found. It carries the address of this page.

Issue with "How do you show the build version and git commit in /actuator/info?": https://scrivio-interview-library.netlify.app/spring-boot/actuator/179160e643/