Example 9: Nested Workflows

In this V2.0 syntax example we will look at 2 JSON workflow code snippets. The first sample is that of a Parent workflow calling on the second Child workflow. Nested workflows work by having one workflow call upon a second workflow.

Example 9.1: Parent Workflow

This is the first of two examples explaining nested workflows. This example shoes a parent workflow calling a child workflow.

{"name": "SampleParentWorkflow",
  ............
  "workflow": {
    ............
    "plan": {
      "steps": [
        {
          "name": "MyParentFirstStep",
           ............
           "publish":{ 
                "MyParentFirstStepVar1":"MyParentFirstStepVar1Value",
            }
        }
        {
          "name": "MyParentWorkflowStep",
          "vars": {
             ............
             "variable6": "var6",
             ............
             "variable100": "var100",
          },
          "operation": {
            "type": "WORKFLOW",
            "parameters": {
              "workflow": {
                "name": "MyWorkflowName",
                "source": "MySourceName",
                "version": "1.0",
                "reference": {
                  "name": "MyLibWorkflowName",
                  "version": "1.0.0"
                },
                "input": {
                  "vars": {
                    "variable1": "hello world1",
                    "variable2": "${workflow.vars.myGlobalVar}",
                    "variable3": "${workflow.vars.myWf1Var}",
                  },
                  "workerVars": {
                    "wf1": {
                      "variable4": "hello world3",
                      "variable5": "${steps.MyParentFirstStep.result.MyParentFirstStepVar1}"
                    }
                  }
                }
              }
            }
          }
        }
      ]
    },
    "input": {
      "vars": {
        "myGlobalVar": "myGlobalVarValue"
      },
      "workerVars": {
        "wf1": {
         "myWf1Var": "myWf1VarValue"
        }
      }
    }
  }
}
Example 9.2: Child Workflow

This is the second of two examples explaining nested workflows. This example shows the child workflow.

{"name": "SampleChildWorkflow",
  ............
  "workflow": {
    ............
    "plan": {
      "steps": [
        {
          "name": "MyChildStep1",
           ............
        }
        {
          "name": "MyChildStep2",
        }
      ],
      "publish":{ 
                "MyChildWfVar1":"MyChildWfVar1Value",
                "MyChildWfVar2":"MyChildWfVar2Value",
        }
    },
    "input": {
      "vars": {
         "variable1" : "Child1",
         "variable2" : "Child2",
         "variableChild1": "variableChild1Value"
      },
      "workerVars": {
        "wf1": {
         "myWf1Var": "myChildWf1VarValue1",
         "myChildWf1Var2": "myChildWf1VarValue2",
         "myChildWf1Var3": "myChildWf1VarValue3"
        },
        "wf2": {
         "myWf1Var": "myWf1VarValue"
        },
        "wf3": {
         "myWf1Var": "myWf1VarValue"
        }
      }
    }
  }
}