create-pipeline-v1
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseCreate Pipeline v1
创建Pipeline v1
Generate Harness v1 simplified Pipeline YAML and optionally push to Harness via MCP.
Alpha: This skill is currently in internal testing only.
生成Harness v1简化版Pipeline YAML,并可选择通过MCP推送到Harness。
Alpha阶段:本技能目前仅内部测试可用。
Instructions
操作说明
- Confirm v1 format - User must specifically want v1 syntax. Default to v0 () if unclear.
/create-pipeline - Clarify requirements - Pipeline type (CI, CD, or both), language/framework, deployment target
- Consult the spec reference - Use for the complete v1 schema, step types, action catalog, and examples
references/v1-spec-schema.md - Select native actions - Always prefer native action and template steps over steps. Consult
run:for the full mapping. Key rules:references/native-actions.md- Docker build/push → use /
template: uses: buildAndPushToDocker/buildAndPushToECR(neverbuildAndPushToGAR)run: docker build && docker push - K8s deploy → use or
action: uses: kubernetes-rolling-deploy(nevertemplate: uses: k8sRollingDeployStep)run: kubectl apply - Helm deploy → use or
action: uses: helm-deploy(nevertemplate: uses: helmDeployBasicStep)run: helm upgrade --install - ECS deploy → use (never
template: uses: ecsBluegreenDeployStep)run: aws ecs update-service - Terraform → use (never
template: uses: terraformStep)run: terraform apply - Security scanning → use native STO templates (,
gitleaksStep,banditStep)sbomOrchestrationStep - Uploads → use /
template: uses: uploadArtifactsToS3(neveruploadArtifactsToGCS)run: aws s3 cp - Approvals → use or
approval: uses: harness(never polling scripts)approval: uses: jira - Ticketing → use /
action: uses: jira-create(neversnow-create)run: curl - HTTP requests → use or
action: uses: http(nevertemplate: uses: httpStep)run: curl - Use steps only for custom build/test/lint commands with no native equivalent
run:
- Docker build/push → use
- Generate v1 YAML using flat structure, expressions,
${{ }}field for run steps, andscript/actionsteps for deploymentstemplate - Optionally create via MCP using with resource_type
harness_createpipeline
- 确认v1格式 - 用户必须明确需要v1语法。若不确定,默认使用v0()。
/create-pipeline - 明确需求 - 流水线类型(CI、CD或两者兼具)、语言/框架、部署目标
- 参考规范文档 - 使用获取完整v1 schema、步骤类型、动作目录及示例
references/v1-spec-schema.md - 选择原生动作 - 优先使用原生动作和模板步骤,而非步骤。查阅
run:获取完整映射。核心规则:references/native-actions.md- Docker构建/推送 → 使用/
template: uses: buildAndPushToDocker/buildAndPushToECR(绝不要用buildAndPushToGAR)run: docker build && docker push - K8s部署 → 使用或
action: uses: kubernetes-rolling-deploy(绝不要用template: uses: k8sRollingDeployStep)run: kubectl apply - Helm部署 → 使用或
action: uses: helm-deploy(绝不要用template: uses: helmDeployBasicStep)run: helm upgrade --install - ECS部署 → 使用(绝不要用
template: uses: ecsBluegreenDeployStep)run: aws ecs update-service - Terraform → 使用(绝不要用
template: uses: terraformStep)run: terraform apply - 安全扫描 → 使用原生STO模板(、
gitleaksStep、banditStep)sbomOrchestrationStep - 上传 → 使用/
template: uses: uploadArtifactsToS3(绝不要用uploadArtifactsToGCS)run: aws s3 cp - 审批 → 使用或
approval: uses: harness(绝不要用轮询脚本)approval: uses: jira - 工单 → 使用/
action: uses: jira-create(绝不要用snow-create)run: curl - HTTP请求 → 使用或
action: uses: http(绝不要用template: uses: httpStep)run: curl - 仅当没有原生等效方案时,才使用步骤执行自定义构建/测试/检查命令
run:
- Docker构建/推送 → 使用
- 生成v1 YAML - 使用扁平化结构、表达式、run步骤的
${{ }}字段,以及部署用的script/action步骤template - 可选通过MCP创建 - 使用,resource_type设为
harness_createpipeline
v1 Key Differences from v0
v1与v0的核心差异
| v0 Syntax | v1 Syntax |
|---|---|
| |
| Flat stages -- no |
| |
Native steps ( | Action steps ( |
| |
| |
Deep nesting ( | Flat structure ( |
| |
| v0语法 | v1语法 |
|---|---|
| |
| 扁平化阶段——无 |
Run步骤中的 | |
原生步骤( | 动作步骤( |
| |
| |
深度嵌套( | 扁平化结构( |
阶段 | |
Pipeline Structure
流水线结构
yaml
pipeline:
name: My Pipeline
repo: # optional: repository config
connector: account.github
name: myorg/my-repo
clone: # optional: clone config
depth: 1
on: # optional: event triggers
- push:
branches: [main]
env: # optional: global env vars
NODE_ENV: production
inputs: # optional: pipeline inputs
branch:
type: string
default: main
stages:
- name: build
steps:
- run:
script: go buildNo , , or wrapper -- is the root key.
version:kind:spec:pipeline:yaml
pipeline:
name: My Pipeline
repo: # 可选:仓库配置
connector: account.github
name: myorg/my-repo
clone: # 可选:克隆配置
depth: 1
on: # 可选:事件触发器
- push:
branches: [main]
env: # 可选:全局环境变量
NODE_ENV: production
inputs: # 可选:流水线输入
branch:
type: string
default: main
stages:
- name: build
steps:
- run:
script: go build无需、或包裹——为根键。
version:kind:spec:pipeline:Stages
阶段
Stages have no field. Their purpose is determined by their keys.
type阶段无字段,其用途由自身键值决定。
typeCI Stage
CI阶段
yaml
- name: build
runtime: cloud
platform:
os: linux
arch: arm
cache:
path: node_modules
key: npm.${{ branch }}
steps:
- run:
script: npm ciyaml
- name: build
runtime: cloud
platform:
os: linux
arch: arm
cache:
path: node_modules
key: npm.${{ branch }}
steps:
- run:
script: npm ciDeployment Stage
部署阶段
yaml
- name: deploy
service: my-service
environment: staging
steps:
- action:
uses: kubernetes-rolling-deploy
with:
dry-run: falseyaml
- name: deploy
service: my-service
environment: staging
steps:
- action:
uses: kubernetes-rolling-deploy
with:
dry-run: falseApproval (stage-level)
审批(阶段级)
yaml
- approval:
uses: harness
with:
timeout: 30m
message: "Approve deployment?"
groups: [admins, ops]
min-approvers: 1yaml
- approval:
uses: harness
with:
timeout: 30m
message: "是否批准部署?"
groups: [admins, ops]
min-approvers: 1Step Types
步骤类型
Run Step
Run步骤
Uses field (not or ).
script:command:run:yaml
undefined使用字段(而非或)。
script:command:run:yaml
undefinedlong syntax
完整语法
- run: script: npm test
- run: script: npm test
short syntax
简化语法
- run: npm test
- run: npm test
with container
带容器
- run: container: node:18 script: npm test
- run: container: node:18 script: npm test
with shell and env
带Shell和环境变量
- run: shell: bash script: | npm ci npm test env: NODE_ENV: test
- run: shell: bash script: | npm ci npm test env: NODE_ENV: test
with output variables
带输出变量
- id: build run: script: echo "TAG=v1" >> $HARNESS_OUTPUT output: [TAG]
undefined- id: build run: script: echo "TAG=v1" >> $HARNESS_OUTPUT output: [TAG]
undefinedRun Test Step
Run Test步骤
yaml
- run-test:
container: maven
script: mvn test
report:
type: junit
path: target/surefire-reports/*.xml
splitting:
concurrency: 4yaml
- run-test:
container: maven
script: mvn test
report:
type: junit
path: target/surefire-reports/*.xml
splitting:
concurrency: 4Action Step
Action步骤
Actions replace v0 native steps. See for the full action catalog.
references/v1-spec-schema.mdyaml
undefined动作替代了v0的原生步骤。查阅获取完整动作目录。
references/v1-spec-schema.mdyaml
undefinedKubernetes deploy
Kubernetes部署
- action: uses: kubernetes-rolling-deploy with: dry-run: false
- action: uses: kubernetes-rolling-deploy with: dry-run: false
Helm deploy
Helm部署
- action: uses: helm-deploy with: timeout: 10m
- action: uses: helm-deploy with: timeout: 10m
Terraform plan
Terraform计划
- action: uses: terraform-plan with: command: apply aws-provider: account.aws_connector
- action: uses: terraform-plan with: command: apply aws-provider: account.aws_connector
HTTP request
HTTP请求
- action: uses: http with: method: GET endpoint: https://acme.com
undefined- action: uses: http with: method: GET endpoint: https://acme.com
undefinedBackground Step
Background步骤
yaml
- background:
container: redis
- run:
script: npm testyaml
- background:
container: redis
- run:
script: npm testTemplate Step
Template步骤
yaml
- template:
uses: account.docker@1.0.0
with:
push: true
tags: latestyaml
- template:
uses: account.docker@1.0.0
with:
push: true
tags: latestApproval Step (inline)
审批步骤(内联)
yaml
- approval:
uses: jira
with:
connector: account.jira
project: PROJyaml
- approval:
uses: jira
with:
connector: account.jira
project: PROJParallel and Group
并行与分组
yaml
undefinedyaml
undefinedparallel steps
并行步骤
- parallel:
steps:
- run: script: npm run lint
- run: script: npm test
- parallel:
steps:
- run: script: npm run lint
- run: script: npm test
parallel stages
并行阶段
- parallel:
stages:
- steps:
- run: go test
- steps:
- run: npm test
- steps:
- parallel:
stages:
- steps:
- run: go test
- steps:
- run: npm test
- steps:
step group
步骤分组
- group:
steps:
- run: script: go build
- run: script: go test
undefined- group:
steps:
- run: script: go build
- run: script: go test
undefinedStrategy
策略
yaml
undefinedyaml
undefinedmatrix (stage-level)
矩阵(阶段级)
- strategy:
matrix:
node: [16, 18, 20]
os: [linux, macos]
max-parallel: 3
steps:
- run: container: node:${{ matrix.node }} script: npm test
- strategy:
matrix:
node: [16, 18, 20]
os: [linux, macos]
max-parallel: 3
steps:
- run: container: node:${{ matrix.node }} script: npm test
matrix (step-level)
矩阵(步骤级)
- strategy: matrix: go: [1.19, 1.20, 1.21] run: container: golang:${{ matrix.go }} script: go test
undefined- strategy: matrix: go: [1.19, 1.20, 1.21] run: container: golang:${{ matrix.go }} script: go test
undefinedFailure Strategy
失败策略
yaml
undefinedyaml
undefinedstep-level
步骤级
- run: script: go test on-failure: errors: all action: ignore # abort, ignore, retry, fail, success
- run: script: go test on-failure: errors: all action: ignore # abort、ignore、retry、fail、success
retry with attempts
带重试次数的重试
- run: script: go test on-failure: errors: [unknown] action: retry: attempts: 5 interval: 10s failure-action: fail
- run: script: go test on-failure: errors: [unknown] action: retry: attempts: 5 interval: 10s failure-action: fail
stage-level
阶段级
- steps:
- run: script: go test on-failure: errors: all action: abort
undefined- steps:
- run: script: go test on-failure: errors: all action: abort
undefinedConditional Execution
条件执行
yaml
undefinedyaml
undefinedstage conditional
阶段条件
- if: ${{ branch == "main" }}
steps:
- run: script: deploy.sh
- if: ${{ branch == "main" }}
steps:
- run: script: deploy.sh
step conditional
步骤条件
- if: ${{ branch == "main" }} run: script: deploy.sh
undefined- if: ${{ branch == "main" }} run: script: deploy.sh
undefinedComplete CI Example
完整CI示例
yaml
pipeline:
repo:
connector: account.github
name: myorg/my-app
clone:
depth: 1
on:
- push:
branches: [main]
- pull_request:
branches: [main]
stages:
- name: build-and-test
runtime: cloud
platform:
os: linux
arch: arm
cache:
path: node_modules
key: npm.${{ branch }}
steps:
- run:
script: npm ci
- parallel:
steps:
- run:
script: npm run lint
- run-test:
script: npm test
report:
type: junit
path: junit.xml
- action:
uses: docker-build-push
with:
connector: dockerhub
repo: myorg/my-app
tags: [${{ pipeline.sequenceId }}, latest]yaml
pipeline:
repo:
connector: account.github
name: myorg/my-app
clone:
depth: 1
on:
- push:
branches: [main]
- pull_request:
branches: [main]
stages:
- name: build-and-test
runtime: cloud
platform:
os: linux
arch: arm
cache:
path: node_modules
key: npm.${{ branch }}
steps:
- run:
script: npm ci
- parallel:
steps:
- run:
script: npm run lint
- run-test:
script: npm test
report:
type: junit
path: junit.xml
- action:
uses: docker-build-push
with:
connector: dockerhub
repo: myorg/my-app
tags: [${{ pipeline.sequenceId }}, latest]Complete CD Example
完整CD示例
yaml
pipeline:
inputs:
skip_dry_run:
type: boolean
default: false
stages:
- name: deploy-staging
service: petstore
environment: staging
steps:
- action:
uses: manifest-download
- action:
uses: manifest-bake
- action:
uses: kubernetes-rolling-deploy
with:
dry-run: ${{ inputs.skip_dry_run }}
- approval:
uses: harness
with:
timeout: 1d
message: "Approve production deployment?"
groups: [prod-approvers]
min-approvers: 1
- name: deploy-prod
service: petstore
environment: prod
steps:
- action:
uses: manifest-download
- action:
uses: manifest-bake
- action:
uses: kubernetes-rolling-deploy
with:
dry-run: falseyaml
pipeline:
inputs:
skip_dry_run:
type: boolean
default: false
stages:
- name: deploy-staging
service: petstore
environment: staging
steps:
- action:
uses: manifest-download
- action:
uses: manifest-bake
- action:
uses: kubernetes-rolling-deploy
with:
dry-run: ${{ inputs.skip_dry_run }}
- approval:
uses: harness
with:
timeout: 1d
message: "是否批准生产环境部署?"
groups: [prod-approvers]
min-approvers: 1
- name: deploy-prod
service: petstore
environment: prod
steps:
- action:
uses: manifest-download
- action:
uses: manifest-bake
- action:
uses: kubernetes-rolling-deploy
with:
dry-run: falseCreating via MCP
通过MCP创建
- Verify the project exists — List projects with (resource_type:
harness_list, org_id) to confirm. If the project does not exist, create it first withproject(resource_type:harness_create, body:project) or ask the user.{ identifier, name } - Create the pipeline — Use with the v1 pipeline YAML serialized as a
harness_createstring in the body. Do not pass a nested JSONyamlPipelineobject; it causes serialization errors.pipeline
Call MCP tool: harness_create
Parameters:
resource_type: "pipeline"
org_id: "<organization>"
project_id: "<project>"
body: { yamlPipeline: "<full v1 pipeline YAML string, including 'pipeline:' root key>" }- 验证项目存在 — 使用(resource_type:
harness_list, org_id)列出项目进行确认。若项目不存在,先使用project(resource_type:harness_create, body:project)创建,或询问用户。{ identifier, name } - 创建流水线 — 使用,将v1流水线YAML序列化为**
harness_create**字符串放入body中。请勿传递嵌套JSON格式的yamlPipeline对象,否则会导致序列化错误。pipeline
调用MCP工具: harness_create
参数:
resource_type: "pipeline"
org_id: "<organization>"
project_id: "<project>"
body: { yamlPipeline: "<完整v1流水线YAML字符串,包含'pipeline:'根键>" }Examples
示例
Create a v1 CI pipeline
创建v1 CI流水线
/create-pipeline-v1
Create a v1 CI pipeline for a Node.js app with caching, parallel lint and test, and Docker push/create-pipeline-v1
为Node.js应用创建带缓存、并行检查和测试、Docker推送的v1 CI流水线Create a v1 deployment pipeline
创建v1部署流水线
/create-pipeline-v1
Create a v1 Kubernetes deployment pipeline with staging approval and production stages/create-pipeline-v1
创建带预发布环境审批和生产环境阶段的v1 Kubernetes部署流水线Create a v1 matrix build
创建v1矩阵构建
/create-pipeline-v1
Create a v1 pipeline that tests across Go 1.19, 1.20, and 1.21 using matrix strategy/create-pipeline-v1
创建使用matrix策略在Go 1.19、1.20和1.21版本进行测试的v1流水线Performance Notes
性能注意事项
- Always check before using a
references/native-actions.mdstep. Native actions provide better error handling, rollback support, and UI integration.run: - Always consult for the complete v1 spec before generating YAML.
references/v1-spec-schema.md - Use field in run steps, never
script:orcommand:as the field name.run: - Use or
action: uses:for deployments, never v0 native step types liketemplate: uses:.K8sRollingDeploy - Do not mix v0 and v1 syntax. No expressions, no
<+...>on stages, notype:wrapper.spec: - Validate all expressions use syntax before presenting.
${{ }}
- 使用步骤前务必查阅
run:。原生动作提供更优的错误处理、回滚支持和UI集成。references/native-actions.md - 生成YAML前务必查阅获取完整v1规范。
references/v1-spec-schema.md - run步骤中使用字段,绝不要用
script:或command:作为字段名。run: - 部署时使用或
action: uses:,绝不要用v0原生步骤类型如template: uses:。K8sRollingDeploy - 不要混合v0和v1语法。禁止使用表达式、阶段的
<+...>字段、type:包裹层。spec: - 展示前验证所有表达式使用语法。
${{ }}
Troubleshooting
故障排查
Common v1 Syntax Errors
常见v1语法错误
- Using instead of
<+...>expressions${{ ... }} - Adding field on stages (v1 stages have no type)
type: - Using or
command:as the field name instead ofrun:script: - Wrapping pipeline in ,
version:,kind:(v1 uses barespec:)pipeline: - Using v0 step types () instead of actions (
K8sRollingDeploy)action: uses: kubernetes-rolling-deploy - Using instead of
failureStrategies:on-failure:
- 使用而非
<+...>表达式${{ ... }} - 为阶段添加字段(v1阶段无类型)
type: - 使用或
command:作为字段名而非run:script: - 用、
version:、kind:包裹流水线(v1直接使用spec:)pipeline: - 使用v0步骤类型()而非动作(
K8sRollingDeploy)action: uses: kubernetes-rolling-deploy - 使用而非
failureStrategies:on-failure:
MCP Errors
MCP错误
- Project not found — Verify the project exists with (resource_type:
harness_list, org_id). Create it first or confirm org_id/project_id are correct.project - Missing required fields for pipeline: pipeline — Pass the body as instead of a nested JSON
{ yamlPipeline: "<full v1 pipeline YAML string>" }object.pipeline - — Pipeline exists; use
DUPLICATE_IDENTIFIERharness_update - — Check YAML structure matches v1 schema
INVALID_REQUEST
- 项目未找到 — 使用(resource_type:
harness_list, org_id)验证项目是否存在。先创建项目或确认org_id/project_id正确。project - Missing required fields for pipeline: pipeline — 将body传递为,而非嵌套JSON格式的
{ yamlPipeline: "<完整v1流水线YAML字符串>" }对象。pipeline - — 流水线已存在;使用
DUPLICATE_IDENTIFIERharness_update - — 检查YAML结构是否匹配v1 schema
INVALID_REQUEST