Variables

All of the environment variables defined on Platform.sh Professional are available on Platform.sh Enterprise as well, and function the same.

Additionally, the following environment variables are defined on an Enterprise cluster. They may be used in a deploy hook, for instance, to execute certain tasks only when running on an Enterprise cluster.

  • PLATFORM_MODE: Set to enterprise in an Enterprise environment (both production and staging).
  • PLATFORM_CLUSTER: Set to the cluster ID. This is usually the same as your project name.
  • PLATFORM_PROJECT: Set to the project name. In most cases this will be the same as the cluster name in production and have a _stg suffix on staging.

How can I have a script behave differently on the cluster than on development?

The following sample shell script will output a different value on the Enterprise cluster than the Development environment.

if [ "PLATFORM_MODE" = "enterprise" ] ; then
    echo "Hello from the Enterprise"
else
    echo "We're on Development"
fi

How can I have a script behave differently on Production and Staging?

The following sample script will output a different value on Production than on Staging. This assumes the project name is "inkinc", a popular ink retailer. You will need to modify the name accordingly.

if [ "PLATFORM_PROJECT" = "inkinc_stg" ] ; then
    echo "We're just staging"
else
    echo "This is live on production"
fi

results matching ""

    No results matching ""