使用 hub resolver 指定远程流水线

功能概述

Pipeline 是用于 CI/CD 流程的可复用构建块。 在创建 pipeline run 时,您可以从 Hub 上可用的 Catalog 中指定一个远程流水线。 我们为您提供了一个默认的 Hub 实例可供使用。

步骤

1. 选择一个 Pipeline

Hub 上可用的流水线如下:

  • java-image-build-scan-deploy
  • python-image-build-scan-deploy

2. 使用 hub resolver 指定远程流水线

要指定远程流水线,请在 pipelineRef 中使用以下引用格式:

# ...
spec:
  pipelineRef:
    resolver: hub
    params:
    - name: catalog
      value: catalog
    - name: kind
      value: pipeline
    - name: name
      value: <resource_name>
    - name: version
      value: "<resource_version>"
# ...
参数描述示例值
catalog用于拉取资源的 catalog。catalog
kind可以是 task 或 pipeline。pipeline
name要从 hub 中获取的 task 或 pipeline 的名称。java-image-build-scan-deploy
version要从 hub 中获取的 task 或 pipeline 的版本。数字周围必须使用引号 (")。"0.1"

如果 pipeline 需要其他参数,请在 pipeline run 规范的 params 部分指定这些参数的值。 pipelineRef 规范中的 params 部分只能包含 resolver 支持的参数。

示例:

下面的示例 pipeline run 引用了 catalog 中的一个远程流水线:

apiVersion: tekton.dev/v1
kind: PipelineRun
metadata:
  name: hub-pipeline-reference-demo
spec:
  pipelineRef:
    resolver: hub
    params:
    - name: catalog
      value: catalog
    - name: kind
      value: pipeline
    - name: name
      value: java-image-build-scan-deploy
    - name: version
      value: "0.1"
  params:
  - name: sample-pipeline-parameter
    value: test

了解更多