출력 파라미터(Output Parameters)
출력 파라미터는 스텝의 결과를 아티팩트가 아니라 파라미터로 사용하는 일반적인 메커니즘이에요. 조건 판단, 루프, 인수 전달에서 script가 아닌 모든 스텝 타입의 결과를 활용할 수 있어요.
본문
출력 파라미터는 스텝의 결과를 (아티팩트가 아니라) 파라미터로 사용할 수 있는 일반적인 메커니즘을 제공해요. 이를 통해 script뿐 아니라 모든 타입의 스텝 결과를 조건 판단, 루프, 인수에 사용할 수 있어요. 출력 파라미터는 script result와 비슷하게 동작하지만, 값이 stdout 내용이 아니라 생성된 파일의 내용으로 설정된다는 점이 달라요.
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:
# Pass the hello-param output from the generate-parameter step as the message input to print-message
- name: message
value: "{{steps.generate-parameter.outputs.parameters.hello-param}}"
- name: hello-world-to-file
container:
image: busybox
command: [sh, -c]
args: ["echo -n hello world > /tmp/hello_world.txt"] # generate the content of hello_world.txt
outputs:
parameters:
- name: hello-param # name of output parameter
valueFrom:
path: /tmp/hello_world.txt # set the value of hello-param to the contents of this hello-world.txt
- name: print-message
inputs:
parameters:
- name: message
container:
image: busybox
command: [echo]
args: ["{{inputs.parameters.message}}"]
DAG 템플릿은 다른 태스크를 참조할 때 tasks 접두사를 사용해요. 예: {{tasks.generate-parameter.outputs.parameters.hello-param}}.
생성하는 스텝이나 태스크가 스킵되거나 생략되었다면, 출력 파라미터에 valueFrom.default를 선언해 그 경우의 값을 제공할 수 있어요.
이런 참조가 어떻게 해석되는지는 Outputs of Skipped and Omitted Nodes를 참고하세요.
result 출력 파라미터
script와 container 템플릿에서 result 출력 파라미터는 표준 출력을 최대 256 kb까지 담아요.
HTTP 템플릿에서는 result가 응답 본문을 담아요.
outputs 맵에서 접근할 수 있어요: outputs.result.
스크립트(Scripts)
script의 출력은 표준 출력에 할당되고 result 파라미터로 수집돼요. 자세한 내용은 여기를 참고하세요.
컨테이너(Containers)
컨테이너 스텝과 태스크도 표준 출력이 result 파라미터로 수집돼요.
log-int라는 task가 있다면 result는 {{ tasks.log-int.outputs.result }}로 접근할 수 있어요. steps를 사용한다면 tasks를 steps로 바꾸세요: {{ steps.log-int.outputs.result }}.
HTTP
HTTP 템플릿은 응답 본문이 비어 있지 않으면 result 파라미터에 응답 본문을 담아요.
더 알아보기 (Learn more)
- 스크립트 표준 출력과
result파라미터의 상세 동작은 scripts-and-results 문서를 참고하세요. - 스킵·생략 노드의 출력 참조 해석은 variables.md의 Outputs of Skipped and Omitted Nodes 섹션을 확인하세요.
- 아티팩트로 결과를 전달해야 한다면 출력 아티팩트(output artifacts)와 함께 설계하는 편이 좋아요.