This topic describes concepts related to pipelines, including pipelines and pipeline templates, tasks and task templates, and execution contexts.
Background
App Center introduces the concepts of pipelines and pipeline templates. A pipeline references a pipeline template and provides an execution context. It describes a single pipeline execution and its results. A pipeline template defines a flow by outlining tasks and their dependencies.
App Center also introduces the concepts of tasks and task templates. A task references a task template and provides an execution context. It describes a single task execution and its results. A task template defines how a task executes by specifying its execution method and an optional preset context.
The introduction of tasks and task templates separates the description of task execution from the pipeline. This simplifies pipeline descriptions and lets you build pipelines modularly, similar to using building blocks.
Pipeline
A pipeline is an execution of a pipeline template. For example, you can set a trigger rule for a code repository. If a build and publish action is required for every push event, App Center creates a pipeline object each time a user pushes code to the repository. This object records the execution details and results.

Pipeline template

Task
Tasks are the primary components of a pipeline. A task describes the execution and results of each independent step in the pipeline. Typically, a task is not run individually. Instead, all tasks are generated by a pipeline run. For example, after a build and deployment pipeline completes, it sequentially generates three independent tasks: build, approval, and deployment. The build task is a separate execution responsible for building the target artifact from the code in the repository.
A task can output its results as text or in a structured format. If the task produces file or image artifacts, these artifacts must be saved during task execution.
Based on template restrictions and the execution context input, a task can run in an Alibaba Cloud sandbox environment or in your current account.

Task template
A task template defines how a task executes by specifying its execution method and an optional preset context. To simplify the getting-started process, App Center provides several common, preset task templates, such as approval, deployment, and custom execution. You can also create new templates to implement custom logic. Task templates greatly simplify pipeline descriptions.
Execution context
The execution context (Context) serves as the input that influences the specific behavior of pipelines and tasks. When a qualifying Git event occurs or a pipeline is manually triggered, a pipeline object is created. The contextual information from the trigger is then parameterized and passed into the execution context.
When a pipeline runs, it creates and executes tasks. The execution engine merges the pipeline's execution context, denoted as ctx_pipeline, with the preset execution context of the pipeline template, denoted as ctx_pipelinetemplate. The result is a new execution context for the task, denoted as ctx_task. When the task executes, the execution engine then merges the task's execution context with the task template's execution context, denoted as ctx_tasktemplate. The result is the final runtime execution context for the task, denoted as ctx.
If the + operator is used to describe the merge action, merging context ctx_1 into context ctx_2 is written as ctx_1 + ctx_2. The merge logic described above can be expressed as ctx_task = ctx_pipeline + ctx_pipelinetemplate and ctx = ctx_task + ctx_tasktemplate. This can also be expressed as ctx = ctx_pipeline + ctx_pipelinetemplate + ctx_tasktemplate. The following figure shows an example.

App Center clearly defines this merge behavior. The objects to be merged are JSON objects, and the implementation follows the JSON Merge Patch standard. For example, ctx_1 + ctx_2 means that the data in ctx_1 has higher priority and overwrites the data in ctx_2 to create a new JSON object.
Additionally, the merge behavior does not follow the commutative law. For example, ctx_1 + ctx_2 is not equal to ctx_2 + ctx_1. ctx_1 + ctx_2 represents merging ctx_1 into ctx_2, while ctx_2 + ctx_1 represents merging ctx_2 into ctx_1. The following figure shows the behavior and results of both operations.

When a task executes, its execution context is merged into the template's preset execution context to create the final execution context. The node where the task runs receives a request that contains this final execution context and executes the corresponding logic.
