步骤间参数传递
将当前 step 的结果导出为Output Parameter
将前一个 step 的Output Parameter
导入为当前步骤的Input Parameter
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 apiVersion: argoproj.io/v1alpha1 kind: Workflow metadata: generateName: output-parameter- spec: entrypoint: output-parameter templates: - name: output-parameter steps: - - name: generate-parameter template: hello-world-to-file - - name: consume-parameter template: print-message arguments: parameters: - name: message value: "{{steps.generate-parameter.outputs.parameters.hello-param}} " - name: hello-world-to-file container: image: busybox command: [sh , -c ] args: ["echo -n Output And Input Test > /tmp/hello_world.txt" ] outputs: parameters: - name: hello-param valueFrom: path: /tmp/hello_world.txt - name: print-message inputs: parameters: - name: message container: image: busybox command: [echo ] args: ["{{inputs.parameters.message}} " ]
在arguments.parameters
中直接引用了之前步骤的Output Parameter
,语法为 {{steps.$stepName.outputs.parameters.$parameterName}}
。
内置的 result 参数 除了手动导出的参数之外,ArgoWorkflow
还会默认生成一个Output Parameter
,就是result
。和其他Output Parameter
一样,可以通过 {{steps.$stepName.outputs.parameters.$parameterName}}
语法进行引用。这个result
参数会捕获最大256KB
的标准输出作为value
。
因此result
包含以下内容:
只要是在容器中输出到标准输出的,内容都可以被result
捕获。
script 的运行结果 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 apiVersion: argoproj.io/v1alpha1 kind: Workflow metadata: generateName: scripts-bash- spec: entrypoint: bash-script-example templates: - name: bash-script-example steps: - - name: generate template: gen-random-int-python - - name: print template: print-message arguments: parameters: - name: message value: "{{steps.generate.outputs.result}} " - name: gen-random-int-python script: image: python:alpine3.6 command: [python ] source: | import random i = random.randint(1, 100) print(i) - name: print-message inputs: parameters: - name: message container: image: alpine:latest command: [sh , -c ] args: ["echo result was: {{inputs.parameters.message}} " ]
容器的标准输出 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 apiVersion: argoproj.io/v1alpha1 kind: Workflow metadata: generateName: scripts-bash- spec: entrypoint: bash-script-example templates: - name: bash-script-example steps: - - name: generate template: whalesay-logs - - name: print template: print-message arguments: parameters: - name: message value: "{{steps.generate.outputs.result}} " - name: whalesay-logs container: image: docker/whalesay command: [sh , -c ] args: ["cowsay test container logs" ] - name: print-message inputs: parameters: - name: message container: image: alpine:latest command: [sh , -c ] args: ['echo result was: "{{inputs.parameters.message}} "' ]
相关具体信息见,官方文档链接