With Spring Boot Actuator, we get some endpoints that display information about our application. One of the endpoints is the /info endpoint. If our project uses Git, we can add information about Git to the /info endpoint. By default, Spring Boot will look for a file git.properties in the classpath of our application. The file is a Java properties file with keys that start with git. and have values like the branch name, commit identifier, and commit message.

Spring Boot uses this information, and when we request the /info endpoint, we get a response with the information. This can be very useful to check the Git information that was used to build the application. To create the git.properties file, we can use a Gradle (or Maven) plugin that will do the work for us.

In the following example, we use the Gradle plugin to generate the git.properties file for our project. The Gradle Git properties plugin is added in the plugins configuration block. The plugin adds a Gradle extension gitProperties that can be used to customize the output in git.properties. We could even change the location (but we keep it to the default location build/resources/main/git.properties).

We can even show more information by changing the Spring Boot configuration property management.git.info.mode. The default value is SIMPLE, but we can also use the value FULL. Then, we get the Git commit message and user details. We can set the configuration property in different ways for our Spring Boot application (for example, in application.yml, Java system property or environment variable). In our example, we add a Java system property to the Gradle bootRun task: