Review scenario steps

In the hook configuration, each scenario is an XML file that contains steps to run build, deploy, or post-deploy tasks. For example, the scenario/transfer file includes three steps: compress-static-content, clear-init-directory, and backup-data

scenario/transfer.xml

<?xml version="1.0"?>
<scenario xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:ece-tools:config/scenario.xsd">
    <step name="compress-static-content" type="Magento\MagentoCloud\Step\Build\CompressStaticContent" priority="100"/>
    <step name="clear-init-directory" type="Magento\MagentoCloud\Step\Build\ClearInitDirectory" priority="200"/>
    <step name="backup-data" type="Magento\MagentoCloud\Step\Build\BackupData" priority="300">
        <arguments>
            <argument name="logger" xsi:type="object">Psr\Log\LoggerInterface</argument>
            <argument name="steps" xsi:type="array">
                <item name="static-content" xsi:type="object" priority="100">Magento\MagentoCloud\Step\Build\BackupData\StaticContent</item>
                <item name="writable-dirs" xsi:type="object"  priority="200">Magento\MagentoCloud\Step\Build\BackupData\WritableDirectories</item>
            </argument>
        </arguments>
    </step>
</scenario>

Extend a default scenario

The following example extends the default deploy scenario by appending additional deploy configuration files to the hook configuration.

hooks:
  deploy: |
    php ./vendor/bin/ece-tools run scenario/deploy.xml vendor/<vendor-name>/<module-name>/deploy.xml vendor/<vendor-name>/<module-name>/deploy2.xml

During deployment, the custom scenarios merge with the default scenario-based on the following rules:

  • Scenarios are prioritized based on their sequence in the hook definition with the last scenario listed having the highest priority.

    In the example, the scenarios have the following priority:

    1. vendor/vendor-name/module-name/deploy2.xml
    2. vendor/vendor-name/module-name/deploy.xml
    3. scenario/deploy.xml (default or baseline scenario)
  • The steps in the highest priority scenario override steps with the same name in the other scenarios. New steps are added to the configuration. The same rules apply for more than two scenarios with each scenario being prioritized from right to left, for example (C → B → A).