Day #2 with Cloud Workflows: a workflow is made of steps or even jumps!

Guillaume Laforge
Dec 2, 2020 · 1 min read

Let’s continue our discovery of Cloud Workflows!

Yesterday, we discovered the UI of Cloud Workflows. We created our first workflow. We started with a single step, returning a greeting message:

- sayHello:
return: Hello from Cloud Workflows!

A workflow definition is made of steps. But not just one! You can create several steps. In YAML, the structure of your workflow will be something like:

- stepOne:
# do something
- stepTwo:
# do something else
- sayHello:
return: Hello from Cloud Workflows!

By default, steps are executed in the order they appear, from top to bottom. The execution will finish when either you return a value, or you reach the final step. If there’s no return statement, a null value is returned as result of the workflow execution.

A small step for a workflow execution, but you can also do a jump between steps! For that, you’ll use the next instruction:

- stepOne:
next: stepTwo
- stepThree:
next: sayHello
- stepTwo:
next: stepThree
- sayHello:
return: Hello from Cloud Workflows!

Here, we jump between steps, back and forth, before going to the final step that will return a value, and thus finish the execution of our workflow.

Of course, we can go beyond a linear series of steps, and in subsequent articles, we’ll see how we can create conditional jumps and switches, for more complex logic, and how we can pass some data and values between steps.

Originally published at http://glaforge.appspot.com.

Google Cloud - Community

Google Cloud community articles and blogs

Google Cloud - Community

A collection of technical articles and blogs published or curated by Google Cloud Developer Advocates. The views expressed are those of the authors and don't necessarily reflect those of Google.

Guillaume Laforge

Written by

Developer Advocate for Google Cloud Platform, Apache Groovy programming language project VP/Chair

Google Cloud - Community

A collection of technical articles and blogs published or curated by Google Cloud Developer Advocates. The views expressed are those of the authors and don't necessarily reflect those of Google.