This topic describes the terms that are related to pipelines, including pipeline, pipeline template, task, task template, and context.

Overview

Pipelines and pipeline templates are used in Serverless Application Center. A pipeline describes a pipeline execution and the execution result by referencing a pipeline template and providing the execution context. A pipeline template describes an execution process by describing tasks and dependencies between tasks.

Tasks and task templates are used in pipelines of Serverless Application Center to describe execution steps of pipelines and the execution methods. A task provides the execution context that describes an execution step in a pipeline and the execution result by referencing a task template. A task template describes the execution methods of tasks and provides the option to preset context to specify how tasks are executed.

The use of tasks and task templates makes the description of task execution unnecessary in pipelines. The concepts of task and task template in Serverless Application Center simplify the description of pipelines and help users build custom pipelines with ease.

Pipeline

A pipeline is an execution of a pipeline template. For example, if a trigger rule is configured for a code repository, a build and release operation is performed during each push event. Each time a user pushes code to the code repository, a pipeline object is created in Serverless Application Center to record the execution in detail, including the execution results. The following figure shows an example.

pipeline-concept1

Pipeline template

A pipeline template is a description of a continuous integration and continuous deployment (CI/CD) scenario, such as the build and release scenario. A pipeline template specifies the process of a specific CI/CD scenario by describing tasks and dependencies between tasks. A pipeline template can be reused. For example, in a build and deployment scenario, you need to build a product based on the code in the code repository and release the product to the cloud after it is approved. The following figure shows the dependencies between the build, approval, and deployment tasks. pipeline-concept2

Task

Tasks are the main components of pipelines. A task describes an execution step in a pipeline and the execution result. In most cases, users do not run a separate task. Tasks in a pipeline are generated when a pipeline is run. For example, when a build and deployment pipeline is triggered, the following three independent tasks are generated in sequence: build, approval, and deployment. The build task is independently executed to build products based on the code in the code repository.

The execution results of tasks can be output as texts or structs. Files and images that are generated must be saved during the task execution.

A task can be executed in an Alibaba Cloud sandbox environment or in the current account based on the template specifications and execution context.

pipeline-task-concept

Task template

A task template describes the execution methods of tasks and provides the option to preset context to specify how tasks are executed. Serverless Application Center provides common task templates, such as approval, deployment, and custom execution tasks. You can also create a new template to implement custom logic. Task templates can simplify pipeline description.

Execution context

Execution contexts affect how pipelines and tasks are executed and act as inputs of pipelines and tasks. When a Git event that meets specific conditions is generated or triggers pipelines, a pipeline object is created. The trigger context is parameterized and passed to the execution context.

During pipeline execution, tasks are generated and executed. The execution engine merges the execution context of the pipeline (ctx_pipeline) into the execution context preset in the pipeline template (ctx_pipelinetemplate) to generate a new execution context as the execution context of the task (ctx_task). When a task is being executed, the execution engine merges the task execution context with the execution context of the task template (ctx_tasktemplate) as the execution context of the task (ctx).

If the + operator is used to describe the merging action, the merging of the execution context ctx_1 into the execution context ctx_2 can be recorded as ctx_1+ctx_2. The preceding merging logic can be described as ctx_task=ctx_pipeline+ctx_pipelinetemplate and ctx=ctx_task+ctx_tasktemplate. The merging logic can also be described as ctx=ctx_pipeline+ctx_pipelinetemplate+ctx_tasktemplate. The following figure shows the details.

pipeline-template-task

The merging action is explicitly defined in Serverless Application Center. The merged object is a JSON object, and the implementation standard of merging is JSON Merge Patch. For example, ctx_1+ctx_2 specifies that the data in ctx_1 has a higher priority. The data in ctx_2 is overwritten and a new JSON object is generated.

The merging behavior does not support the commutative law. For example, ctx_1+ctx_2 is not the same as ctx_2+ctx_1. ctx_1+ctx_2 specifies that ctx_1 is merged into ctx_2, while ctx_2+ctx_1 specifies that ctx_2 is merged into ctx_1. The following figure shows the behavior and results of each action.

context-merge

When a task is executed, the execution context of the task is merged with the execution context preset in the template and used as the final execution context. The node where the task is located receives a request that contains the execution context and executes the corresponding logic based on the context.

pipeline-context-merge