0

I have a spring boot project and I would like to add some information for the info endpoint.

To add the spring-boot-actuator I added it to the gradle.build. Now, I want to have something like this:

{
    "app" : {
        "version" : "1.0.0",
        "description" : "my program",
        "name" : "my program",
        "build-time" : "2016-04-08_06-26-53",
        "build-tag" : "jenkins-infinity-sprint-5023",
        "revision": "849604ec53b91d7903732f07eb3ca79c8f8dcf2b",
}

}

I want to get most of the values from a properties file which can be filled out at compilation time. My first approach is to have this:

# application.properties

info.app.description=my program
info.app.name=my program
info.app.build-time=${System.env['BUILD_ID']}
info.app.build-tag=${System.env['BUILD_TAG']}
info.app.revision=${System.env['MERCURIAL_REVISION']}
info.app.version=${version}

But the JSON response I am getting when I call to /info is this one:

{
    "app": {
        "build-time": "${System.env['BUILD_ID']}"
        "version": "${version}"
        "description": "my program"
        "revision": "${System.env['MERCURIAL_REVISION']}"
        "build-tag": "${System.env['BUILD_TAG']}"
        "name": "my program"
    }
}

First of all I don't know why the values are not substituted. What am I doing wrong?

My original idea is to fill in in the Manifest.mf file all the values I would need, do you know how to do it?

Daniel Olszewski
  • 13,995
  • 6
  • 58
  • 65
Manuelarte
  • 1,658
  • 2
  • 28
  • 47

1 Answers1

1

You have to add the filtering task to gradle explicitly, something like:

processResources() {
    filesMatching("application.properites") {
        filter(ReplaceTokens, tokens:  [
                'build-time': System.env['BUILD_ID']
        ])
    }
}

Your property file should use @ placeholders:

info.app.build-time=@build-time@
David Siro
  • 1,826
  • 14
  • 33
  • It is not working, I am getting: "build-time": "@build-time@" – Manuelarte May 10 '16 at 13:18
  • It looks like `filesMatching(...)` doesn't pick your your file. The path in my snippet is obviously informative, you should replace it with location of your file. – David Siro May 10 '16 at 13:22