added check result function when running a process model from the shell script
This commit is contained in:
parent
1a84f4802f
commit
17dd287541
|
@ -27,6 +27,15 @@ fi
|
|||
|
||||
modified_process_model_identifier=$(tr '/' ':' <<<"$process_model_identifier")
|
||||
|
||||
function check_result_for_error() {
|
||||
local result="$1"
|
||||
error_code=$(jq '.error_code' <<<"$result")
|
||||
if [[ -n "$error_code" ]]; then
|
||||
>&2 echo "ERROR: Failed to run process instance. Received error: $result"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
function process_next_task() {
|
||||
local next_task="$1"
|
||||
|
||||
|
@ -37,6 +46,7 @@ function process_next_task() {
|
|||
|
||||
if grep -qE "Manual ?Task" <<<"$task_type" && [[ "${task_state}" == "READY" ]]; then
|
||||
next_task=$(curl --silent -X PUT "${BACKEND_BASE_URL}/v1.0/tasks/${process_instance_id}/${task_guid}" -H "Authorization: Bearer $access_token")
|
||||
check_result_for_error "$next_task"
|
||||
process_next_task "$next_task"
|
||||
elif [[ "$(jq '.ok' <<<"$next_task")" == "null" ]]; then
|
||||
echo -e "\n\nThe next task is not a Manual Task and requires user input. It must be completed manually."
|
||||
|
@ -55,5 +65,6 @@ if ! grep -qE '^[0-9]+$' <<<"$process_instance_id"; then
|
|||
fi
|
||||
|
||||
result=$(curl --silent -X POST "${BACKEND_BASE_URL}/v1.0/process-instances/${modified_process_model_identifier}/${process_instance_id}/run" -H "Authorization: Bearer $access_token")
|
||||
check_result_for_error "$result"
|
||||
next_task=$(jq '.next_task' <<<"$result")
|
||||
process_next_task "$next_task"
|
||||
|
|
Loading…
Reference in New Issue