Steps (original) (raw)

To create a workflow, you define the steps you want and their order of execution using the Workflows syntax. Every workflow must have at least one step.

By default, Workflows treats steps as if they are in an ordered list and executes them one at a time until all the steps have run. For example, this workflow has two steps:

YAML

JSON

[ { "STEP_NAME_A": { ... } }, { "STEP_NAME_B": { ... } }, ]

Step names

Step names must be unique at thesubworkflow level. For example, in the following workflow, a step named init is allowed in both the mainblock and the subworkflow.

YAML

main: params: [input] steps: - init: call: sub sub: steps: - init: assign: - a: 0

JSON

{ "main": { "params": [ "input" ], "steps": [ { "init": { "call": "sub" } } ] }, "sub": { "steps": [ { "init": { "assign": [ { "a": 0 } ] } } ] } }

Workflows doesn't enforce a naming convention for step names. However, we recommend consistent usage such as creating step names that only include alphanumeric characters and underscores.

Step types

Workflows supports various types of steps, including the following:

Implicit step ordering

This sample shows implicit step ordering within a workflow. By default, the steps of a workflow are executed in the order they appear in the workflow definition.

YAML

JSON

Nested steps

You can use a steps block to nest a series of steps and further define a workflow:

YAML

JSON

{
  STEP_NAME: {
  "steps": [
    {
      STEP_NAME_1: {
        "steps": [
          {
            STEP_NAME_A:
              ...
          },
          {
            STEP_NAME_B:
              ...
          }
        ]
      }
    },
    {
      STEP_NAME_2: {
        "steps": [
          {
            STEP_NAME_C:
              ...
          }
        ]
      }
    }
  ]
}

}

Variables declared in a steps block have workflow-level scope and can be accessed outside of the block. Any step type can be nested inside of a stepsblock including assign, call, and switch. For example:

YAML

main: steps: - series_one: steps: - step_a: call: http.get args: url: https://host.com/api1 result: api_response1 - step_b: assign: - varA: "Monday" - varB: "Tuesday" - series_two: steps: - step_c: call: http.get args: url: https://host.com/api2 result: api_response2 - step_d: assign: - varC: "Wednesday" - varD: "Thursday"

JSON

{ "main": { "steps": [ { "series_one": { "steps": [ { "step_a": { "call": "http.get", "args": { "url": "https://host.com/api1" }, "result": "api_response1" } }, { "step_b": { "assign": [ { "varA": "Monday" }, { "varB": "Tuesday" } ] } } ] } }, { "series_two": { "steps": [ { "step_c": { "call": "http.get", "args": { "url": "https://host.com/api2" }, "result": "api_response2" } }, { "step_d": { "assign": [ { "varC": "Wednesday" }, { "varD": "Thursday" } ] } } ] } } ] } }

Note that in some cases, steps is required; for example, when defining asubworkflow or a for loop.