Skip to content

Instantly share code, notes, and snippets.

@jmcdice
Last active May 30, 2018 20:28
Show Gist options
  • Save jmcdice/3780662b26b4eb0e640c9eade0753ce8 to your computer and use it in GitHub Desktop.
Save jmcdice/3780662b26b4eb0e640c9eade0753ce8 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
TARGET='concourse'
TASK='deploy-healthwatch/apply-changes'
function wait_for_pipeline_to_complete() {
local JOB=$1
local count=1
while true; do
local STATUS=$(concourse_task_status $JOB)
if [ "$STATUS" = 'succeeded' ]; then
echo "$JOB: Complete."
break
elif [ "$STATUS" = 'failed' ]; then
echo "$JOB: Failed."
break
elif [ "$STATUS" = 'aborted' ]; then
echo "$JOB: Aborted."
break
else
# Check every 10 seconds but print status every 1200 seconds.
if ! (( $count % 120 )); then
echo "$JOB ($count): $STATUS"
sleep 10
fi
(( count++ ))
fi
done
}
function concourse_task_status() {
local JOB=$1
STATUS=$(fly -t ${TARGET} builds | egrep "$JOB" | sort | tail -1 | awk '{print $4}')
if [ -z "$STATUS" ]; then
echo "Not yet run"
return
fi
echo "$STATUS"
}
wait_for_pipeline_to_complete $TASK
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment