Spring Boot Actuator provides several "production ready" endpoints to simplify development.

The "info" endpoint returns a JSON response including all properties that start with "info" and we’ve chosen to surface the name, version and commit id via Gradle.

Here’s how:

jar {
    baseName = 'myapplication'
compileJava.dependsOn 'writeInfo'

version = "1.0.${System.getenv().BUILD_NUMBER}.${System.getenv().GIT_COMMIT?.toString()?.substring(0,3)}"

task writeInfo() {
    new File('src/main/resources/info.properties').text = "info.name=${jar.baseName}\ninfo.version=${version}\ninfo.commit=${System.getenv().GIT_COMMIT}\n"

This causes the build info to be packaged into deployable artifact (jar file) named:


and actuator/info returns:

  "version": "",
  "name": "myapplication",
  "commit": "2a61a8d63e5bd738840b02e2e6e9a033e119990d"

QED :-)