How to extend / adjust

How to extend pipeline definitions

Adjustable pipeline elements

Nodes such as pipelines, steps, or conditions can get extended.

For this purpose, the corresponding blocks can get provided with a reference prefix.

  • Accordingly, pipeline becomes referencePipeline or step_condition becomes referenceStep_condition

  • Any attributes of a _reference node_ get mapped to the _original node_

  • The _child elements_ of the reference node get merged into the _original node_

Example

<referencePipeline name="my_pipeline" description="new description">
    <conditions>
        <pipeline_condition type="new_condition_two"/>
    </conditions>
    <step name="new_step" sortOrder="200">
        <conditions>
            <step_condition type="pip_one_step_condition_one"/>
            <referenceStep_condition type="old_condition" remove="true"/>
        </conditions>
    </step>
    <referenceStep name="existing_step" sortOrder="5"/>
</referencePipeline>

Allowed Reference Nodes

Original Node Reference Node

/pipeline

/referencePipeline

/pipeline/conditions/pipeline_condition

/referencePipeline/conditions/referencePipeline_condition

/pipeline/step

/referencePipeline/referenceStep

/pipeline/step/arguments/argument

/referencePipeline/referenceStep/arguments/referenceArgument

/pipeline/step/conditions/step_condition

/referencePipeline/referenceStep/conditions/referenceStep_condition

/pipeline/step/conditions/recurring_condition

/referencePipeline/referenceStep/conditions/referenceRecurring_condition

Change/extend pipeline properties

  • With reference, pipelines can get edited and extended

  • As well as any other information can get edited and overwritten

Example

<referencePipeline name="my_pipeline" description="new description">
    <conditions>
        <pipeline_condition type="new_condition_two"/>
    </conditions>
    <step name="new_step" sortOrder="200">
        <conditions>
            <step_condition type="pip_one_step_condition_one"/>
            <referenceStep_condition type="old_condition" remove="true"/>
        </conditions>
    </step>
    <referenceStep name="existing_step" sortOrder="5"/>
</referencePipeline>

Description for referencePipeline Blocks

Node Description

referencePipeline

Definition of an existing pipeline.

  • By means of the name attribute, existing pipelines can get overwritten or extended

– name

Required: string

  • Unique identifier, which gets used for instantiating a pipeline by CLI

  • Can be used for condition rules

– description

Optional: string

  • Pipeline description

  • 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 during pipeline instantiation

The path for this directory is configurable and can be retrieved within an executor by
$step->getWorkingDir()

– expire-in

Optional: string

  • Defines the execution time after which the pipeline is cancelled

– remove

Optional: boolean

  • Removes the referenced original pipeline during the delete process

  • See

In case there are further references to a deleted pipeline, they will get logged as well.

referencePipeline/conditions

Optional

  • One or multiple conditions which should be set to true to cause a new pipeline execution

  • See

referencePipeline/conditions/pipeline_condition

Optional

  • Configuration of a pipeline condition

referencePipeline/conditions/referencePipeline_condition

Optional

  • One or multiple conditions which should be set to true to cause a new pipeline execution

  • See

– type

Required: string

  • Defines the class, which will get executed to run the condition check

  • It is also the identifier of this condition

– description

Optional: string

  • Description text for a given condition

  • It will get displayed on UI, logs, CLI

– remove

Optional: boolean

  • If set to true, the original condition gets removed

referencePipeline/step

Optional

  • Add a new step to the referenced pipeline

referencePipeline/referenceStep

Optional

  • Edit an existing step in an existing pipeline See

Change/extend step properties

  • The Minor Magento version 2.3.0 allows editing and extending steps by reference

  • Any information can get edited and overwritten

Example

<referencePipeline name="pipeline_one">
   <referenceStep name="change_sort_order_of_step" sort_order="120"/>
</referencePipeline>

Description for referencePipeline Blocks

Node Description

referencePipeline/referenceStep

Definition of an existing step.

  • Existing steps can get overwritten or extended using the attribute Name

– name

Required: string

  • Unique identifier

  • Is used for running/executing the step by CLI, can be used for condition rules

– expireIn

Optional: string

  • Defines the maximum execution time of the step

  • If the time is exceeded, the pipeline will be cancelled

– sortOrder

Optional: string

  • Definition of step sorting

  • Helpful in resorting to the steps by other modules and extensions

– description

Optional: string

  • Description text for a given step

  • Will be displayed on UI, logs, CLI, …​

– executorType

Required: string

  • Defines the class, which will get executed to run the step

– runAlwaysStep

Optional: boolean

  • If the flag is set, the step will get executed in any case, Even if the pipeline gets canceled or abandoned.

  • A kind of final-Step defines the class, which will get executed to run the step

– remove

Optional: boolean

  • This optional flag removes the referenced original step during the deleting process

  • If there are further references to a deleted step, they will get logged

referencePipeline/referenceStep/conditions

Optional

  • One or multiple conditions that should be set to true to cause the step execution

referencePipeline/referenceStep/conditions/condition

Optional

  • Adds a condition

referencePipeline/referenceStep/conditions/referenceCondition

Optional

  • Overwrites an existing condition

– type

Required: string

  • Defines the class, which will get executed to run the condition check

  • It is the identifier of this condition

– description

Optional: string

  • The Description text for a given condition

  • The Description will get displayed on UI, logs, CLI, …​

– remove

Optional: boolean

  • Deletes an existing condition

referencePipeline/referenceStep/arguments

Optional

  • Holds one or many executor arguments

referencePipeline/referenceStep/arguments/referenceArgument

Optional

  • Extends an Argument

– key

Required: string

  • Required for identification

– value

Optional: string

  • Overwrites the original value of the referenced argument

– remove

Optional: boolean

  • If set to true, the existing argument will get removed

Modify existing step conditions

  • An existing pipeline must get referenced

  • Following, you can use a reference to an existing step

  • Then, conditions can get added in the same way as they get added to a newly created step

  • The attribute remove="true", an existing condition, can get deleted

Example

<referencePipeline name="pip_one">
    <step name="possible_duplicated_stepname" sortOrder="200">
        <conditions>
            <step_condition type="new_step_condition"/>
            <referenceStep_condition type="existing_condition" remove="true"/>
        </conditions>
    </step>
</referencePipeline>

Edit existing pipeline condition

  • An existing pipeline has to get referenced

  • Following, you can use a reference to an existing step

  • After that, conditions can get added in the same way as they get added to a new created pipeline

  • An existing condition can get deleted with the attribute remove="true"

Example

<referencePipeline name="my_pipeline">
    <conditions>
        <pipeline_condition type="new_condition"/>
        <referencePipeline_condition type="old_condition" remove=”true”/>
    </conditions>
</referencePipeline>

Add steps to pipeline

  • An existing pipeline must be referenced

  • Following this, a step can get added in the same way as for a new created pipeline

Example

<referencePipeline name="my_pipeline">
    <step name="do_something" executorType="MyCompany\MyModule\Model\Executor\DoSmthExecutor" sortOrder="120" description="Try to do something"/>
</referencePipeline>

Remove existing pipeline step

To remove an existing step from a pipeline, the reference definition is needed.

Example

<referencePipeline name="abc">
    <referenceStep name="existing_step_name" remove="true"/>
</referencePipeline>

Remove existing pipeline

To delete a pipeline (not to deactivate a pipeline), the reference definition is needed.

Example

<referencePipeline name="abc" remove="true"/>
  • All further references to the deleted pipeline get then noted in the log file

Replace/override pipeline

To completely replace a pipeline, it must get removed and then added again.

Example

<referencePipeline name="abc" remove="true"/>
<pipeline name="abc">
<step name="a" executorType="MyCompany\MyModule\Model\Executor\DoSmthExecutor" sortOrder="10"/>
</pipeline>

How to extend pipeline logic and workflow

Extend init pipeline

In step one, you must implement a custom model for the interface TechDivision\PacemakerPipelineInitializer\Api\InitializationDataFetcherInterface.

In Step two, you must register your implementation to the DataFetcher-Chain:
<type name="TechDivision\PacemakerPipelineInitializer\Model\InitializationDataFetcherChain">
    <arguments>
        <argument name="dataFetcher" xsi:type="array">
            <item name="pacemaker.order.export" xsi:type="object">TechDivision\PacemakerOrderExport\Model\PipelineInitializer</item>
        </argument>
    </arguments>
</type>

To execute the dataFetcher implementation, enable the configuration for using Init-Pipeline to generate a pipeline

Output

pipeline inizialiazer

Prevention the initialization of pipelines

Initialization prevention of the pipeline in the command line.

As the following step, register the excludedPipelines to TechDivision\ProcessPipelines\Console\InitCommand to prevent initialization of the pipeline in the config:
<type name="TechDivision\ProcessPipelines\Console\InitCommand">
    <arguments>
        <argument name="excludedPipelines" xsi:type="array">
            <item name="pacemaker_order_export" xsi:type="string">pacemaker_order_export</item>
        </argument>
    </arguments>
</type>
Next, register the excludedFromSource to TechDivision\ProcessPipelines\Config\Config:
<type name="TechDivision\ProcessPipelines\Config\Config">
    <arguments>
        <argument name="excludedFromSource" xsi:type="array">
            <item name="pacemaker_order_export" xsi:type="string">pacemaker_order_export</item>
        </argument>
    </arguments>
</type>

Register virtual pipeline

Besides the pipeline definition via XML, pipelines can also be programmed. These dynamic or virtual pipelines cannot be managed by default.

In order for the pipeline to be manageable via the backend, it must be registered via DI. This requires a PipelineProvider and the registration information.

Here is standard Pacemaker Order Export for example:
<type name="TechDivision\ProcessPipelines\Model\RegisterVirtualPipelines">
    <arguments>
        <argument name="virtualPipelines" xsi:type="array">
            <item name="pacemaker_order_export" xsi:type="array">
                <item name="name" xsi:type="string">pacemaker_order_export</item>
                <item name="config_provider" xsi:type="object">TechDivision\PacemakerOrderExport\Model\ExportPipelineConfigurationProvider</item>
            </item>
        </argument>
    </arguments>
</type>

Once this has been done, the pipeline registered in this way is available in the backend for creation, in the cleanup functionality, in the monitoring tool and also via the CLI context.

Exclude pipeline for manual creation

It is possible to exclude pipelines from manual initialisation. To do this, only two di-entries need to be made.

Exclude pipelines form initialization in Magento backend:
<type name="TechDivision\ProcessPipelines\Config\Config">
    <arguments>
        <argument name="excludedFromSource" xsi:type="array">
            <item name="pacemaker_order_export" xsi:type="string">pacemaker_order_export</item>
        </argument>
    </arguments>
</type>
Exclude pipelines form initialization with CLI:
<type name="TechDivision\ProcessPipelines\Console\InitCommand">
    <arguments>
        <argument name="excludedPipelines" xsi:type="array">
            <item name="pacemaker_order_export" xsi:type="string">pacemaker_order_export</item>
        </argument>
    </arguments>
</type>