Define Environment Variables

Page last updated:

Page last updated:

Cloud Foundry lets you externalize configuration - storing data such as encryption keys or external resource addresses in environment variables.

At runtime, environment variables are exposed to the application through its environment. You can use these for example to change the default version of Java to 7 by setting the JBP_CONFIG_OPEN_JDK_JRE environment variable accordingly:

$ cf set-env my-clojure-app JBP_CONFIG_OPEN_JDK_JRE '{ "jre": { "version": "1.7.0_+" } }'
Setting env variable 'JBP_CONFIG_OPEN_JDK_JRE' to '{jre: { version: 1.7.0_+ }}' for app my-clojure-app in org MyOrg / space MySpace as user@smydomain.com...
OK
TIP: Use 'cf restage' to ensure your env variable changes take effect

Then restage your app as suggested using

$ cf restage my-clojure-app
Restaging app my-clojure-app in org MyOrg / space MySpace as user@mydomain.com...
-----> Downloaded app package (13M)
-----> Downloaded app buildpack cache (79M)
Cloning into '/tmp/buildpacks/java-buildpack'...
-----> Java Buildpack Version: bed4c61 | https://github.com/cloudfoundry/java-buildpack.git#bed4c61

...
I’ve set my environment variable
View the source for this page in GitHub