1

我正在创建一个部署管道,它将包作为 Python 包部署到 Pypi 或 Docker 容器。我想确保通过处理工作区的内容并将判断(或)传递给下游任务中的块来调用正确的部署任务"Python""Docker"when

问题是,当我将结果传递给一个when块时,它与值不匹配,即使我相信它应该,就像我将结果记录在创建它的任务中,甚至将它分配给一个参数并将其记录在下游任务它具有预期的内容。

没有块的管道when执行没有问题。

系统信息:

$ tkn version
Client version: 0.15.0
Pipeline version: v0.24.1
Triggers version: v0.8.1

$ k version --short
Client Version: v1.19.0
Server Version: v1.19.0+b00ba52

管道中的相关任务:

- name: check-appropriate-build-task
  taskRef:
    kind: Task
    name: check-build-type
  workspaces:
    - name: source
      workspace: shared-workspace
  runAfter:
    - fetch-repository

- name: build-and-upload-python-package
  params:
    - name: TWINE_REPOSITORY_URL
      value: $(params.twine-url)
  when:
    - input: $(tasks.check-appropriate-build-task.results.build-type)
      operator: in
      values: 
        - "Python"
  taskRef:
    kind: Task
    name: upload-pypi
  workspaces:
    - name: source
      workspace: shared-workspace
  runAfter:
    - check-appropriate-build-task

检查构建类型任务:

apiVersion: tekton.dev/v1beta1
kind: Task
metadata:
  name: check-build-type
spec:
  results:
    - name: build-type
  workspaces:
    - name: source
  steps:
    - name: check-build-type
      image: alpine
      script: |
        if test -f "$(workspaces.source.path)/setup.cfg"; then
          if grep -q Python "$(workspaces.source.path)/setup.cfg"; then
              echo "Python" > $(results.build-type.path)
          fi
        elif test -f "$(workspaces.source.path)/Dockerfile"; then
            echo "Docker" > $(results.build-type.path)
        fi
        cat $(results.build-type.path)

提前致谢。

4

1 回答 1

1

由于尾随\n.

我们可以修复 check-build-type 任务,替换echoecho -n.

于 2021-08-24T11:54:09.257 回答