使用 hub resolver 指定远程流水线

功能概述

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

步骤

1. 选择流水线

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"

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

示例:

以下示例流水线运行引用了 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

了解更多