create-pipeline-v1

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Create 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

操作说明

  1. Confirm v1 format - User must specifically want v1 syntax. Default to v0 (
    /create-pipeline
    ) if unclear.
  2. Clarify requirements - Pipeline type (CI, CD, or both), language/framework, deployment target
  3. Consult the spec reference - Use
    references/v1-spec-schema.md
    for the complete v1 schema, step types, action catalog, and examples
  4. Select native actions - Always prefer native action and template steps over
    run:
    steps. Consult
    references/native-actions.md
    for the full mapping. Key rules:
    • Docker build/push → use
      template: uses: buildAndPushToDocker
      /
      buildAndPushToECR
      /
      buildAndPushToGAR
      (never
      run: docker build && docker push
      )
    • K8s deploy → use
      action: uses: kubernetes-rolling-deploy
      or
      template: uses: k8sRollingDeployStep
      (never
      run: kubectl apply
      )
    • Helm deploy → use
      action: uses: helm-deploy
      or
      template: uses: helmDeployBasicStep
      (never
      run: helm upgrade --install
      )
    • ECS deploy → use
      template: uses: ecsBluegreenDeployStep
      (never
      run: aws ecs update-service
      )
    • Terraform → use
      template: uses: terraformStep
      (never
      run: terraform apply
      )
    • Security scanning → use native STO templates (
      gitleaksStep
      ,
      banditStep
      ,
      sbomOrchestrationStep
      )
    • Uploads → use
      template: uses: uploadArtifactsToS3
      /
      uploadArtifactsToGCS
      (never
      run: aws s3 cp
      )
    • Approvals → use
      approval: uses: harness
      or
      approval: uses: jira
      (never polling scripts)
    • Ticketing → use
      action: uses: jira-create
      /
      snow-create
      (never
      run: curl
      )
    • HTTP requests → use
      action: uses: http
      or
      template: uses: httpStep
      (never
      run: curl
      )
    • Use
      run:
      steps only for custom build/test/lint commands with no native equivalent
  5. Generate v1 YAML using flat structure,
    ${{ }}
    expressions,
    script
    field for run steps, and
    action
    /
    template
    steps for deployments
  6. Optionally create via MCP using
    harness_create
    with resource_type
    pipeline
  1. 确认v1格式 - 用户必须明确需要v1语法。若不确定,默认使用v0(
    /create-pipeline
    )。
  2. 明确需求 - 流水线类型(CI、CD或两者兼具)、语言/框架、部署目标
  3. 参考规范文档 - 使用
    references/v1-spec-schema.md
    获取完整v1 schema、步骤类型、动作目录及示例
  4. 选择原生动作 - 优先使用原生动作和模板步骤,而非
    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:
      步骤执行自定义构建/测试/检查命令
  5. 生成v1 YAML - 使用扁平化结构、
    ${{ }}
    表达式、run步骤的
    script
    字段,以及部署用的
    action
    /
    template
    步骤
  6. 可选通过MCP创建 - 使用
    harness_create
    ,resource_type设为
    pipeline

v1 Key Differences from v0

v1与v0的核心差异

v0 Syntaxv1 Syntax
<+variable>
expressions
${{ variable }}
expressions
type: CI
/
type: Deployment
stage types
Flat stages -- no
type
field
command:
field in Run steps
script:
field in
run:
steps
Native steps (
K8sRollingDeploy
,
HelmDeploy
)
Action steps (
action: uses: kubernetes-rolling-deploy
)
failureStrategies:
on-failure:
HarnessApproval
step type
approval: uses: harness
(stage-level or inline)
Deep nesting (
spec: execution: steps:
)
Flat structure (
steps:
)
strategy: matrix:
under stage
spec
strategy: matrix:
directly on stage or step
v0语法v1语法
<+variable>
表达式
${{ variable }}
表达式
type: CI
/
type: Deployment
阶段类型
扁平化阶段——无
type
字段
Run步骤中的
command:
字段
run:
步骤中的
script:
字段
原生步骤(
K8sRollingDeploy
HelmDeploy
动作步骤(
action: uses: kubernetes-rolling-deploy
failureStrategies:
on-failure:
HarnessApproval
步骤类型
approval: uses: harness
(阶段级或内联)
深度嵌套(
spec: execution: steps:
扁平化结构(
steps:
阶段
spec
下的
strategy: matrix:
strategy: matrix:
直接定义在阶段或步骤上

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 build
No
version:
,
kind:
, or
spec:
wrapper --
pipeline:
is the root key.
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
type
field. Their purpose is determined by their keys.
阶段无
type
字段,其用途由自身键值决定。

CI Stage

CI阶段

yaml
- name: build
  runtime: cloud
  platform:
    os: linux
    arch: arm
  cache:
    path: node_modules
    key: npm.${{ branch }}
  steps:
  - run:
      script: npm ci
yaml
- name: build
  runtime: cloud
  platform:
    os: linux
    arch: arm
  cache:
    path: node_modules
    key: npm.${{ branch }}
  steps:
  - run:
      script: npm ci

Deployment Stage

部署阶段

yaml
- name: deploy
  service: my-service
  environment: staging
  steps:
  - action:
      uses: kubernetes-rolling-deploy
      with:
        dry-run: false
yaml
- name: deploy
  service: my-service
  environment: staging
  steps:
  - action:
      uses: kubernetes-rolling-deploy
      with:
        dry-run: false

Approval (stage-level)

审批(阶段级)

yaml
- approval:
    uses: harness
    with:
      timeout: 30m
      message: "Approve deployment?"
      groups: [admins, ops]
      min-approvers: 1
yaml
- approval:
    uses: harness
    with:
      timeout: 30m
      message: "是否批准部署?"
      groups: [admins, ops]
      min-approvers: 1

Step Types

步骤类型

Run Step

Run步骤

Uses
script:
field (not
command:
or
run:
).
yaml
undefined
使用
script:
字段(而非
command:
run:
)。
yaml
undefined

long 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]
undefined

Run Test Step

Run Test步骤

yaml
- run-test:
    container: maven
    script: mvn test
    report:
      type: junit
      path: target/surefire-reports/*.xml
    splitting:
      concurrency: 4
yaml
- run-test:
    container: maven
    script: mvn test
    report:
      type: junit
      path: target/surefire-reports/*.xml
    splitting:
      concurrency: 4

Action Step

Action步骤

Actions replace v0 native steps. See
references/v1-spec-schema.md
for the full action catalog.
yaml
undefined
动作替代了v0的原生步骤。查阅
references/v1-spec-schema.md
获取完整动作目录。
yaml
undefined

Kubernetes 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请求

undefined
undefined

Background Step

Background步骤

yaml
- background:
    container: redis
- run:
    script: npm test
yaml
- background:
    container: redis
- run:
    script: npm test

Template Step

Template步骤

yaml
- template:
    uses: account.docker@1.0.0
    with:
      push: true
      tags: latest
yaml
- template:
    uses: account.docker@1.0.0
    with:
      push: true
      tags: latest

Approval Step (inline)

审批步骤(内联)

yaml
- approval:
    uses: jira
    with:
      connector: account.jira
      project: PROJ
yaml
- approval:
    uses: jira
    with:
      connector: account.jira
      project: PROJ

Parallel and Group

并行与分组

yaml
undefined
yaml
undefined

parallel 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
  • parallel: stages:
    • steps:
      • run: go test
    • steps:
      • run: npm test

step group

步骤分组

  • group: steps:
    • run: script: go build
    • run: script: go test
undefined
  • group: steps:
    • run: script: go build
    • run: script: go test
undefined

Strategy

策略

yaml
undefined
yaml
undefined

matrix (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
undefined

Failure Strategy

失败策略

yaml
undefined
yaml
undefined

step-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
undefined

Conditional Execution

条件执行

yaml
undefined
yaml
undefined

stage 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
undefined

Complete 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: false
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: "是否批准生产环境部署?"
        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: false

Creating via MCP

通过MCP创建

  1. Verify the project exists — List projects with
    harness_list
    (resource_type:
    project
    , org_id) to confirm. If the project does not exist, create it first with
    harness_create
    (resource_type:
    project
    , body:
    { identifier, name }
    ) or ask the user.
  2. Create the pipeline — Use
    harness_create
    with the v1 pipeline YAML serialized as a
    yamlPipeline
    string in the body. Do not pass a nested JSON
    pipeline
    object; it causes serialization errors.
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>" }
  1. 验证项目存在 — 使用
    harness_list
    (resource_type:
    project
    , org_id)列出项目进行确认。若项目不存在,先使用
    harness_create
    (resource_type:
    project
    , body:
    { identifier, name }
    )创建,或询问用户。
  2. 创建流水线 — 使用
    harness_create
    ,将v1流水线YAML序列化为**
    yamlPipeline
    **字符串放入body中。请勿传递嵌套JSON格式的
    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
    references/native-actions.md
    before using a
    run:
    step. Native actions provide better error handling, rollback support, and UI integration.
  • Always consult
    references/v1-spec-schema.md
    for the complete v1 spec before generating YAML.
  • Use
    script:
    field in run steps, never
    command:
    or
    run:
    as the field name.
  • Use
    action: uses:
    or
    template: uses:
    for deployments, never v0 native step types like
    K8sRollingDeploy
    .
  • Do not mix v0 and v1 syntax. No
    <+...>
    expressions, no
    type:
    on stages, no
    spec:
    wrapper.
  • Validate all expressions use
    ${{ }}
    syntax before presenting.
  • 使用
    run:
    步骤前务必查阅
    references/native-actions.md
    。原生动作提供更优的错误处理、回滚支持和UI集成。
  • 生成YAML前务必查阅
    references/v1-spec-schema.md
    获取完整v1规范。
  • run步骤中使用
    script:
    字段,绝不要用
    command:
    run:
    作为字段名。
  • 部署时使用
    action: uses:
    template: uses:
    ,绝不要用v0原生步骤类型如
    K8sRollingDeploy
  • 不要混合v0和v1语法。禁止使用
    <+...>
    表达式、阶段的
    type:
    字段、
    spec:
    包裹层。
  • 展示前验证所有表达式使用
    ${{ }}
    语法。

Troubleshooting

故障排查

Common v1 Syntax Errors

常见v1语法错误

  • Using
    <+...>
    instead of
    ${{ ... }}
    expressions
  • Adding
    type:
    field on stages (v1 stages have no type)
  • Using
    command:
    or
    run:
    as the field name instead of
    script:
  • Wrapping pipeline in
    version:
    ,
    kind:
    ,
    spec:
    (v1 uses bare
    pipeline:
    )
  • Using v0 step types (
    K8sRollingDeploy
    ) instead of actions (
    action: uses: kubernetes-rolling-deploy
    )
  • Using
    failureStrategies:
    instead of
    on-failure:
  • 使用
    <+...>
    而非
    ${{ ... }}
    表达式
  • 为阶段添加
    type:
    字段(v1阶段无类型)
  • 使用
    command:
    run:
    作为字段名而非
    script:
  • version:
    kind:
    spec:
    包裹流水线(v1直接使用
    pipeline:
  • 使用v0步骤类型(
    K8sRollingDeploy
    )而非动作(
    action: uses: kubernetes-rolling-deploy
  • 使用
    failureStrategies:
    而非
    on-failure:

MCP Errors

MCP错误

  • Project not found — Verify the project exists with
    harness_list
    (resource_type:
    project
    , org_id). Create it first or confirm org_id/project_id are correct.
  • Missing required fields for pipeline: pipeline — Pass the body as
    { yamlPipeline: "<full v1 pipeline YAML string>" }
    instead of a nested JSON
    pipeline
    object.
  • DUPLICATE_IDENTIFIER
    — Pipeline exists; use
    harness_update
  • INVALID_REQUEST
    — Check YAML structure matches v1 schema
  • 项目未找到 — 使用
    harness_list
    (resource_type:
    project
    , org_id)验证项目是否存在。先创建项目或确认org_id/project_id正确。
  • Missing required fields for pipeline: pipeline — 将body传递为
    { yamlPipeline: "<完整v1流水线YAML字符串>" }
    ,而非嵌套JSON格式的
    pipeline
    对象。
  • DUPLICATE_IDENTIFIER
    — 流水线已存在;使用
    harness_update
  • INVALID_REQUEST
    — 检查YAML结构是否匹配v1 schema