# Spring Boot Actuator show the git and build info
# Introduction
The git and build information can help us for troubleshooting and version control. With Spring Boot Actuator, we can fetch the info just by adding the plugins.
# Integration
Add the actuator dependency:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
Enable the actuator endpoint:
management:
endpoints:
web:
exposure:
include: "*"
now can access /actuator/info, but the response will be empty.
If we need the git and build info, we need to add maven plugin to generate the properties file:
<plugins>
<plugin>
<groupId>pl.project13.maven</groupId>
<artifactId>git-commit-id-plugin</artifactId>
<version>4.0.0</version>
<executions>
<execution>
<id>get-the-git-infos</id>
<goals>
<goal>revision</goal>
</goals>
<phase>initialize</phase>
</execution>
</executions>
<configuration>
<dotGitDirectory>${project.basedir}/.git</dotGitDirectory>
<generateGitPropertiesFile>true</generateGitPropertiesFile>
</configuration>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>${spring-boot-dependencies.version}</version>
<executions>
<execution>
<goals>
<goal>build-info</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
After we run the maven build, it will generate two files for us, one is build-info.properties, another is git.properties:
Now we can restart the application and access the /actuator/info again:
# Code
Code on GitHub: https://github.com/LarryDpk/pkslow-samples
Reference: