Check current version of the running spring-boot app

Are you tired answering “did you deployed latest version” question by your peers/developers? This post is for you.

In fact, I was tired answering my peers that the latest code is deployed. Each time when a bug arises, Dev comes to me asking if I had deployed latest changes. So, I enabled actuator in my spring application, so that anyone can check the version using an end-point.

Below is how you can enable actuator end-point in spring-boot application.

Check this post to see how to enable versioning, so that that versions can be displayed in the actuator end point.

First step to enable actuator is to add a dependency in the application’s build.gradle file as below:

dependencies {
...
compile group: 'org.springframework.boot', name: 'spring-boot-starter-actuator', version: '2.3.3.RELEASE'
...
}

Now — by adding below code in build.gradle, expand the gradle variables to application properties. This is to access versions from gralde to application.

processResources {
expand(project.properties)
}

Next step is to add the version display tag to your application.properties file.

If you are having application.properties file:

info.app.version=${project.version}

If you are having application.yml file:

info:
app:
version: ${project.version}

You are done setting up, now test by following steps.

git add .
git commit -m "Add actuator info"
git tag 1.0.0.test-2
./gradlew clean bootJar
java -jar build/libs/*.java

Now see the output by, navigate to http://localhost:8080/actuator/info

Feel free to reach out me at connect@mevinod.com