我无法通过 CLI 或 TaskRun YAML 将参数传递给 Tekton 任务。
任务文件
apiVersion: tekton.dev/v1beta1
kind: Task
metadata:
name: ubuntu-test
namespace: tekton-pipelines
spec:
params:
- name: var
type: string
steps:
- env:
- name: VAR
value: $(params.var)
image: ubuntu
name: ''
resources: {}
script: |
#!/usr/bin/env bash
echo "Hello from Bash $VAR!"
任务运行文件
apiVersion: tekton.dev/v1beta1
kind: TaskRun
metadata:
name: ubuntu-test-with-parameters
spec:
taskRef:
name: ubuntu-test
params:
- name: var
value:
- "John"
无论我是通过上面的 YAML 文件应用 TaskRun 还是运行,tkn task start --showlog ubuntu-test -p var=John
我都会收到以下输出:
[unnamed-0] Hello from Bash $(params.var)!
环境信息
PS > tkn version
Client version: 0.16.0
Pipeline version: v0.10.1
Triggers version: v0.11.2
Dashboard version: v0.14.0
PS > oc version
Client Version: 4.6.16
Server Version: 4.6.15
Kubernetes Version: v1.19.0+1833054