Spring Boot Actuator provides several "production ready" endpoints to simplify development.
http://docs.spring.io/spring-boot/docs/current/reference/html/production-ready-endpoints.html

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:

myapplication-1.0.16.2a6.jar

and actuator/info returns:

{
  "version": "1.0.16.2a6",
  "name": "myapplication",
  "commit": "2a61a8d63e5bd738840b02e2e6e9a033e119990d"
}

QED :-)