Skip to content

Instantly share code, notes, and snippets.

@sasasin
Created May 6, 2020 13:11
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sasasin/d162938b5e3337423215a5ad533ac7a0 to your computer and use it in GitHub Desktop.
Save sasasin/d162938b5e3337423215a5ad533ac7a0 to your computer and use it in GitHub Desktop.
CodeBuildを待つやつ
#!/bin/bash -e
# AWS CodeBuild のビルドIDを1個だけ受け取り、buildStatus が IN_PROGRESS 以外の状態になるのを、10秒毎、1時間待つ。
# 待っても IN_PROGRESS 以外の状態にならなかったら -1 で終了する。
# https://docs.aws.amazon.com/cli/latest/reference/codebuild/batch-get-builds.html
CODEBUILD_BUILD_ID=$1
# build status check every ${INTERVAL} sec
INTERVAL=10
WAIT_LIMIT=$((${INTERVAL} * 6 * 60))
for i in $(seq 1 ${WAIT_LIMIT}); do
BUILD_STATUS=$(
aws codebuild batch-get-builds --ids ${CODEBUILD_BUILD_ID} | jq -cr '.[][].buildStatus'
)
if [ ${BUILD_STATUS} != "IN_PROGRESS" ]; then
echo "${CODEBUILD_BUILD_ID} ${BUILD_STATUS}"
exit
fi
sleep ${INTERVAL}
done
exit -1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment