Created
December 10, 2019 07:53
-
-
Save Kuchitama/199d91852614a0ba79a79a3d6514b70d to your computer and use it in GitHub Desktop.
digdag scripts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
DIGDAG=~/bin/digdag | |
# see https://github.com/treasure-data/digdag/blob/v0.9.27/digdag-cli/src/main/java/io/digdag/cli/client/ShowAttempts.java#L83-L95 | |
last_result=$($DIGDAG attempts 2>&1 | tail -13); | |
if [[ $last_result =~ ^.+attempt[[:space:]]id:[[:space:]]([0-9]+).+$ ]]; | |
then | |
attempt_id=${BASH_REMATCH[1]}; | |
if [ -z $attempt_id ]; then | |
echo "Cannot find attempt_id" >&2; | |
exit 1; | |
fi | |
fi | |
if [[ $last_result =~ ^.+status:[[:space:]]+(error|success|running)[[:space:]]*+$ ]]; | |
then | |
status=${BASH_REMATCH[1]}; | |
if [ -z $status ]; then | |
echo "Cannot find status" >&2; | |
exit 1; | |
fi | |
if [ $status = 'running' -o $status = 'success' ]; then | |
echo "Cannot resume last attempt[${attempt_id}]. Its status is '${status}'" >&2; | |
exit 1; | |
fi | |
else | |
echo "cannnot find status" | |
exit 1; | |
fi | |
$DIGDAG retry ${attempt_id} --latest-revision --resume |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
DIGDAG=~/bin/digdag | |
# see https://github.com/treasure-data/digdag/blob/v0.9.27/digdag-cli/src/main/java/io/digdag/cli/client/ShowAttempts.java#L83-L95 | |
status=$($DIGDAG attempts 2>&1 | tail -13 | grep 'status' | awk '{print $2}'); | |
if [[ $status =~ ^(error|success|running)$ ]]; then | |
echo $status; | |
if [ $status = 'error' ]; then | |
exit 2; | |
fi | |
else | |
echo "Invalid status found: ${status}" >&2; | |
exit 2; | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment