GCP Workflows: Easy way to re-run failed execution

Viewed 199

Given failed workflow execution (identified by workflow ID and execution ID),
I need a relatively quick and easy way to re-run it using CLI tools (gcloud), with the same input payload.
Asking Google and searching over stackoverflow didn't bring me any easy way to do this.

1 Answers

While the UI offers easy ways to rerun an execution, gcloud doesn't have a shortcut (yet). You could build one with a bit of shell scripting, retrieving the previous arguments and passing them to a new execution:

#/bin/sh
# Usage: ./rerun.sh LOCATION WORKFLOW EXECUTION_ID
DATA=`gcloud workflows executions describe $3 --location $1 --workflow $2 | grep "^argument:" | cut -f2 -d' ' | sed -e "s/^'//" -e "s/'$//"`
gcloud workflows run $2 --location $1 --data=$DATA
Related