Reputation: 109
I have a spring boot app which is built through jenkins pipeline and deployed to pivotal cloud foundry. Suppose I have a properties (application.properties) file with the following value:
API_URL = http://API_URL/
and a reference to that property somewhere in the code. This is to set up environment agnostic builds.
What I want to do is through user provided services on PCF expose that as a VCAP, so that properties file turns into:
API_URL = ${vcap.services.api_url.credentials.url}
I am running the cups command on pcf and binding the service to my app, but when feed the properties file through jenkins pipeline, it errors out complaining that it can't resolve the value mentioned above. I am also including the binding in the manifest.yml file. Folks have stated that spring boot supports resolution of the vcap values out of box however I am not able to achieve this. any thoughts on what I am doing wrong?
Upvotes: 0
Views: 1086
Reputation: 15081
Spring Boot's automatic functionality is described here.
It will basically take the VCAP_SERVICES environment variable and flatten it. It's exposed under vcap.services.*
, with the next bit being the service instance name followed by the properties you expose under the service instance.
If you're having trouble with it, I'd suggest enabling Spring Boot Actuator. It has endpoint which can dump the properties. You can use that to confirm they're available and also view the exact names as it can sometimes be tricky to get the property name exactly right.
For what it's worth, if you only have one property and it's not sensitive you might consider passing that through an env variable instead. It's a little easier to use because of how Spring Boot automatically maps the env variables into properties.
https://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-external-config.html
Hope that helps!
Upvotes: 1