Environment variables

Magento Commerce (Cloud) enables you to assign environment variables to override configuration options:

  • ADMIN—variables override project ADMIN variables
  • Build—variables control build actions
  • Cloud—variables specific to Magento Commerce (Cloud)
  • Deploy—variables control deploy actions
  • Post-deploy—variables control actions after deploy

Variables are hierarchical, which means that if a variable is not overridden, it is inherited from the parent environment.

You can set ADMIN variables from the Project Web interface or using the Magento CLI. Other environment variables can be managed from the .magento.env.yaml file to manage build and deploy actions across all of your environments—including Pro Staging and Production—without requiring a support ticket.

Global variables

The following global variables control actions in the build, deploy, and post-deploy stages of the .magento.env.yaml file. Because global variables impact every stage, you must set them in the global stage. Insert these variables in the global stage of the .magento.env.yaml file:

stage:
  global:
    GLOBAL_VARIABLE_NAME: value

MIN_LOGGING_LEVEL

  • DefaultNot set
  • Version—Magento 2.1.4 and later

Overrides the minimum logging level for all output streams without making changes to the code. This helps to improve troubleshooting problems with deployment. For example, if your deployment fails, you can use this variable to increase the logging granularity globally. See Set up notifications—Log levels. The min_level value in Logging handlers overwrites this setting.

stage:
    global:
        MIN_LOGGING_LEVEL: debug

SCD_ON_DEMAND

  • DefaultNot set
  • Version—Magento 2.1.4 and later

Enable generation of static content when requested by a user. This is ideal for the development and testing workflow, because it decreases the deployment time.

Pre-loading the cache using the post_deploy hook reduces site downtime. The cache warming is available only for Pro projects that contain Staging and Production environments in the Project Web UI and for Starter projects. Add the SCD_ON_DEMAND environment variable to the global stage in the .magento.env.yaml file:

stage:
  global:
    SCD_ON_DEMAND: true

The SCD_ON_DEMAND variable skips the SCD and the STATIC_CONTENT_SYMLINK in both phases (build and deploy), clears the pub/static and var/view_preprocessed folders, and writes the following to the app/etc/env.php file:

return array(
   ...
   'static_content_on_demand_in_production' => 1,
   ...
);

JS bundling and JS/CSS merging do not work with SCD on demand.

SKIP_HTML_MINIFICATION

  • Defaultfalse
  • Version—Magento 2.1.4 and later

Skip copying the static view files in the var/view_preprocessed directory to reduce downtime when deploying to the Staging and Production environments and generates minified HTML when requested.

  • false—Copies the view_preprocessed directory to the <magento_root>/init/ directory at the end of the build stage, and restores the directory in the <magento_root>/var directory at the beginning of the deployment stage.
  • true—Enables on-demand static content minification; does not copy the <magento_root>var/view_preprocessed to the <magento_root>/init/ directory at the end of the build stage.

Add the SKIP_HTML_MINIFICATION environment variable to the global stage in the .magento.env.yaml file:

stage:
  global:
    SKIP_HTML_MINIFICATION: true