Environment Variables on OpenShift

Most of OpenShift’s documentation on setting environment variables has you running commands like this:

$ rhc env set name=value

This is great, but there are a handful of circumstances where it would be better to set variables in your action hooks. Normal bash exports wont work, but OpenShift has a special directory where environment variables exist as files. To create variables, simply add files in the $OPENSHIFT_HOMEDIR/.env/user_vars/ directory, where the filename is the variable name. This allows you to place lines like this in your action hooks:

# pre_start
cd $OPENSHIFT_HOMEDIR/.env/user_vars 

Once created, OpenShift will automatically load this as a persistent environment variable.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s