You need to enable JavaScript to run this app.
文档中心
持续交付

持续交付

复制全文
下载 pdf
流水线
通过 YAML 创建流水线
复制全文
下载 pdf
通过 YAML 创建流水线
持续交付支持通过 YAML 方式创建流水线。本文介绍流水线 YAML 的顶层结构及各配置项的含义、使用方法与取值规范,帮助您以代码化方式一次性定义流水线的源、阶段、任务、步骤及复用组件,并通过版本控制管理流水线。​
背景信息​
流水线即代码(Pipeline as Code)将控制台可视化编排的流水线转为结构化 YAML 文件,支持评审、审计、灰度复用与跨项目迁移。​
  • 代码源(sources):声明流水线触发源与物料,定义流水线的来源及触发方式。​
  • 阶段(stages):按顺序定义交付关键门禁,如构建、测试、部署等流程节点。​
  • 任务(tasks):单个阶段内可并行或串行的任务集合,定义同阶段需执行的各项工作。​
  • 步骤(steps):任务内最小执行单元,定义每项工作的具体执行流程。​
  • 组件(component ):可跨流水线复用的原子能力封装,业务步骤可通过引用组件实现标准化编排。​
层级关系​
​
Pipeline (流水线)​
├── sources (代码源) ── 与 stages 并列,不嵌套​
└── stages (阶段)​
└── stage​
└── tasks (任务)​
└── task​
├── steps (步骤) ← 二选一(指定步骤)​
│ └── step​
│ └── component ← step 通过引用 component 执行​
└── component (组件) ← 二选一(指定组件)​
​
完整示例​
​
version: 2.0.0​
agentPool: public/prod-v2-public​
sources:​
- name: service-connection-demo​
type: Gitee​
url: https://gitee.com/volc-code-pipeline/demo.git​
branch: master​
credential:​
type: serviceConnection​
serviceConnectionId: <your-service-connection-id>​
stages:​
- stage: build​
displayName: build​
tasks:​
- task: cmd-exec​
displayName: command execution​
steps:​
- step: exec-cmd​
displayName: command execution​
component: exec@1.0.0​
inputs:​
shell: BASH​
cmd: echo hello​
resourcesPolicy: all​
timeout: 2h​
resources:​
limits:​
cpu: 1C​
memory: 2Gi​
​
前提条件​
已创建服务连接,操作详情参见 接入代码源。​
操作步骤​
步骤一:进入 YAML 编辑入口​
  1. 在左侧导航栏选择 工作区,在工作区页面单击目标工作区名称,进入当前工作区。​
  1. 单击 创建流水线 > YAML 化编辑。​
  1. 单击 确定,进入当前流水线的 YAML 配置页面。​
步骤二:编写流水线​
按照 YAML语法章节,依次完善 source、stages、tasks、steps 以及可选的 component,详细说明参见 YAML 语法。​
一个最小可运行的流水线 YAML 骨架示例如下:​
​
version: 2.0.0​
agentPool: public/prod-v2-public​
sources:​
- name: service-connection-demo​
type: Gitee​
url: https://gitee.com/volc-code-pipeline/demo.git​
branch: master​
credential:​
type: serviceConnection​
serviceConnectionId: <your-service-connection-id>​
stages:​
- stage: build​
displayName: build​
tasks:​
- task: command execution​
displayName: ​
steps:​
- step: exec-cmd​
displayName: command execution​
component: exec@1.0.0​
inputs:​
shell: BASH​
cmd: echo hello​
resourcesPolicy: all​
timeout: 2h​
resources:​
limits:​
cpu: 1C​
memory: 2Gi​
​
步骤三:校验与保存​
  1. 单击编辑器右下方 校验,CP 将执行 YAML 语法、Schema、引用完整性校验。​
  1. 校验通过后单击 保存,完成创建。​
​
最近更新时间:2026.05.11 11:33:36
这个页面对您有帮助吗?
有用
有用
无用
无用