简体   繁体   中英

How to pass artifacts of one WorkflowTemplate to another WorkflowTemplate from a workflow in argo

I have a workflow template which outputs an artifact, this artifact has to be passed to another workflow template as an input. how we can do that? I'm following the way below which is not working

Here is WorflowTemplate1.yaml

apiVersion: argoproj.io/v1alpha1
kind: WorkflowTemplate
metadata:
  name: arfile
spec:
  entrypoint: main
  templates:
    - name: main
      volumes:
        - name: vol
          emptyDir: {}
      inputs:
        parameters:

      script:
        image: "ubuntu"
        volumeMounts:
          - name: vol
            mountPath: "{{inputs.parameters.Odir}}"
        command: ["bash"]
        source: |
          #!/usr/bin/env bash
          echo "This is artifact testing" > /tmp/arfile

      outputs:
        parameters:
          - name: arfile
            path: "{{inputs.parameters.Odir}}/arfile"

Here is the WorkflowTemplate2.yaml

apiVersion: argoproj.io/v1alpha1
kind: WorkflowTemplate
metadata:
  name: bfile
spec:
  entrypoint: main
  templates:
      - name: main
        volumes:
          - name: vol
            emptyDir: {}
        inputs:
          parameters:
            - name: image
              value: "ubuntu"
            - name: Odir
              value: "/tmp"
          artifacts:
            - name: arfile
              path: /tmp/arfile
        container:
          image: "ubuntu"
          command: ["cat"]
          args:
           - /tmp/arfile

Here is the workflow which is calling the above two workflow templates.I'm unable to pass artifacts of workflowtemplate1 to workflowtemplate2 from this workflow.

apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
  generateName: apr-
spec:
  entrypoint: main
  templates:
    - name: main
      outputs:
        artifacts:
          - name: arfile
            from: "tasks['dfile'].outputs.artifacts.arfile"

      dag:
        tasks:
          - name: dfile
            templateRef:
              name: arfile
              template: main
            arguments:
              parameters:
                - name: bimg
                  value: "ubuntu"

          - name: bci
            depends: dfile
            templateRef:
              name: bfile
              template: main
            arguments:
              parameters:
                - name: img
                  value: "ubuntu"
              artifacts:
                - name: arfile
                  from: "{{tasks.dfile.outputs.artifacts.arfile}}"

What's wrong I'm doing here?

I think I found the issue. I need to use artifacts instead of parameters in WorkflowTemplate1.yaml in outputs code block

here's the fix

outputs:
  artifacts:
    - name: arfile
      path: "{{inputs.parameters.Odir}}/arfile"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM