Created
May 6, 2020 13:11
-
-
Save sasasin/d162938b5e3337423215a5ad533ac7a0 to your computer and use it in GitHub Desktop.
CodeBuildを待つやつ
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 -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