-
Notifications
You must be signed in to change notification settings - Fork 18
/
jenkins-cron-deploy.sh
43 lines (37 loc) · 1.28 KB
/
jenkins-cron-deploy.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
set -e
export name="master-${BUILD_NUMBER}"
echo "Beginning the deploy of build ${BUILD_NUMBER}"
tag="master-${BUILD_NUMBER}"
echo ""
echo "DEPLOYING $tag"
echo ""
# Deploy to prod
aws elasticbeanstalk update-environment \
--environment-name "staffjoy-cron-prod" \
--version-label "$tag"
# Polling to see whether deploy is done
deploystart=$(date +%s)
timeout=1000 # Seconds to wait before error
threshhold=$((deploystart + timeout))
while true; do
# Check for timeout
timenow=$(date +%s)
if [[ "$timenow" > "$threshhold" ]]; then
echo "Timeout - $timeout seconds elapsed"
exit 1
fi
# See what's deployed
version=`aws elasticbeanstalk describe-environments --application-name "stafffjoy-cron" --environment-name "staffjoy-cron-prod" --query "Environments[*].VersionLabel" --output text`
status=`aws elasticbeanstalk describe-environments --application-name "stafffjoy-cron" --environment-name "staffjoy-cron-prod" --query "Environments[*].Status" --output text`
if [ "$version" != "$tag" ]; then
echo "Tag not updated (currently $version). Waiting."
sleep 10
continue
fi
if [ "$status" != "Ready" ]; then
echo "System not Ready -it's $status. Waiting."
sleep 10
continue
fi
break
done