How to configure a pipeline

To define a new pipeline, you need to add a pipeline.xml file into the etc directory of your module.

Here is some sample content for a pipeline.xml file:

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:TechDivision/ProcessPipelines/etc/pipeline.xsd">
    <pipeline name="my_custom_pipeline" description="Some description" use-working-directory="true">
        <conditions>
            <pipeline_condition type="MyCompany\MyModule\Helper\Condition\Pipeline\CheckSomeThing" description="Some description"/>
        </conditions>
        <step name="my_first_step" executorType="MyCompany\MyModule\Model\Executor\DoSomeThing" sortOrder="10" description="" >
            <conditions>
                <step_condition type="TechDivision\ProcessPipelines\Helper\Condition\Step\AttemptsLimit\Limit5" description="Try step up to 5 times"/>
            </conditions>
        </step>
        <step name="my_second_step" executorType="MyCompany\MyModule\Model\Executor\DoSomeMoreStuff" sortOrder="20" description="" >
            <arguments>
                <argument key="some_key" value="some_value" />
            </arguments>
            <conditions>
                <step_condition type="TechDivision\ProcessPipelines\Helper\Condition\Step\PreviousStepsCompleted" description="Run after the first step"/>
                <step_condition type="MyCompany\MyModule\Helper\Condition\Step\CheckSomeThing" description="Check something..."/>
            </conditions>
        </step>
        <step name="my_third_step" executorType="MyCompany\MyModule\Model\Executor\DoClearingStuff" sortOrder="30" description="" runAlwaysStep="true">
            <conditions>
                <step_condition type="TechDivision\ProcessPipelines\Helper\Condition\Step\AttemptsLimit\Limit1" description="Try step up to 1 times"/>
                <step_condition type="TechDivision\ProcessPipelines\Helper\Condition\Step\PreviousStepsFinished" description="Run always when one step started"/>
            </conditions>
        </step>
    </pipeline>
</config>

Description for XML nodes and attributes

Node Description

pipeline

Definition of a new pipeline configuration. You can overwrite or extend existing pipelines by using the same name

-- name

Required, string; Unique identifier, which is used for instantiating a pipeline by CLI and can be used for condition rules, etc.

-- description

Optional, string; Description text for the pipeline. Will be displayed in UI and CLI as 'name' of the pipeline.

-- use-working-directory

Optional, boolean; If defined a working directory will be autogenerated while pipeline instantiation. The path for this directory is configurable and can be retrieved within an executor by $step->getWorkingDir().

pipeline/conditions

Optional; One or multiple conditions which should be true to cause a new pipeline execution

pipeline/conditions/pipeline_condition

Configuration of a pipeline condition

-- type

Required, string; Defines the class, which will be executed to run the condition check.

-- description

Optional, string; Description text for given condition. Will be displayed on UI, logs, CLI, etc.

pipeline/step

Each pipeline has at least one step. The step describes which executor should be run once the step conditions are true

-- name

Required, string; Unique identifier, which is used for running/executing the step by CLI and can be used for condition rules, etc.

-- executorType

Required, string; Defines the class, which will be executed to run the step.

-- sortOrder

Required, string; Defines the sorting of steps. Useful for resorting to the steps by other modules/extensions.

-- description

Optional, string; Description text for given step. Will be displayed on UI, logs, CLI, etc.

-- runAlwaysStep

Optional, boolean; If this flag is set, the step will be executed in any case. Even if the pipeline is canceled or abandoned. Kind of 'finally' step.

pipeline/step/arguments

Optional; Holds one or many executor arguments

pipeline/step/arguments/argument

Step executor argument

-- key/value

Required, string; Since arguments are array at all, both arguments represent the key and value of each array node.

pipeline/step/conditions

One or multiple conditions which should be true to cause the step execution.

pipeline/step/conditions/step_condition

Configuration of a step condition

-- type

Required, string; Defines the class, which will be executed to run the condition check.

-- description

Optional, string; Description text for given condition. Will be displayed on UI, logs, CLI, etc.

There are already some default condition and executors available.