How to set environment variable for a app running on Openshift Online?

Solution Unverified - Updated -

Environment

  • Openshift Online

Issue

  • How to set environment variable for a app running on Openshift Online?

Resolution

  • From a client system, one can set the environment variable using the following command:
# rhc env set test=test --app myphpapp
Setting environment variable(s) ... done
  • SSH to the app and check if the env variable value has been set inside the gear:

# rhc ssh myphpapp Connecting to 523c50ff5004464b1c000001@myphpapp-anande.rhcloud.com ... ********************************************************************* You are accessing a service that is for use only by authorized users. If you do not have authorization, discontinue use at once. Any use of the services is subject to the applicable terms of the agreement which can be found at: https://www.openshift.com/legal ********************************************************************* Welcome to OpenShift shell This shell will assist you in managing OpenShift applications. !!! IMPORTANT !!! IMPORTANT !!! IMPORTANT !!! Shell access is quite powerful and it is possible for you to accidentally damage your application. Proceed with care! If worse comes to worst, destroy your application with "rhc app delete" and recreate it !!! IMPORTANT !!! IMPORTANT !!! IMPORTANT !!! Type "help" for more info. *** This gear has been temporarily unidled. To keep it active, access *** your app @ http://myphpapp-anande.rhcloud.com/ [myphpapp-anande.rhcloud.com 523c50ff5004464b1c000001]\> echo $test test
  • The Environment Variable value can also be checked (from the client system) without SSH'ing to the gear:

# rhc env list --app myphpapp test=test OR # rhc env show test --app myphpapp test=test

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.

Comments