When one workflow step generates a file that the next step needs to process, you can use artifacts to pass the output of one step directly as the input of another. This topic shows how to configure Object Storage Service (OSS) as the artifact repository and pass an artifact between two steps in a workflow.
Prerequisites
Before you begin, ensure that you have:
OSS activated. For more information, see Activate OSS.
OSS configured as the artifact repository for your workflow cluster. For more information, see Configuring Alibaba Cloud OSS.
Pass an artifact between steps
The following example defines a two-step workflow: the first step generates a text file and saves it as an artifact, and the second step retrieves that artifact and prints its contents.
Create a file named
artifact-passing.yamlwith the following content:apiVersion: argoproj.io/v1alpha1 kind: Workflow metadata: generateName: artifact-passing- spec: entrypoint: artifact-example templates: - name: artifact-example steps: - - name: generate-artifact template: whalesay - - name: consume-artifact template: print-message arguments: artifacts: # Bind the message artifact to the hello-art output # from the generate-artifact step. - name: message from: "{{steps.generate-artifact.outputs.artifacts.hello-art}}" - name: whalesay container: image: docker/whalesay:latest command: [sh, -c] args: ["cowsay hello world | tee /tmp/hello_world.txt"] outputs: artifacts: # Save /tmp/hello_world.txt as the hello-art artifact. # The path can be a directory as well as a file. - name: hello-art path: /tmp/hello_world.txt - name: print-message inputs: artifacts: # Unpack the message artifact to /tmp/message. - name: message path: /tmp/message container: image: alpine:latest command: [sh, -c] args: ["cat /tmp/message"]The workflow uses three templates:
Template Role artifact-exampleThe entrypoint template. Runs generate-artifactfirst, then passes itshello-artoutput artifact as themessageinput toconsume-artifact.whalesayWrites text to /tmp/hello_world.txtand declares that file as an output artifact namedhello-art. Thepathfield can point to a directory as well as a single file.print-messageDeclares a messageinput artifact, unpacks it to/tmp/message, and prints the contents withcat.The
fromfield in a steps template uses the{{steps.<step-name>.outputs.artifacts.<artifact-name>}}syntax. If you use a DAG template instead, replacestepswithtasks.Submit the workflow:
argo submit artifact-passing.yamlCheck the workflow status:
argo listA status of
Succeededconfirms that the workflow completed and the artifact was passed successfully.