Skip to content

Instantly share code, notes, and snippets.

@adamgoucher
Created August 4, 2015 23:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save adamgoucher/d111d9fff217f9a91897 to your computer and use it in GitHub Desktop.
Save adamgoucher/d111d9fff217f9a91897 to your computer and use it in GitHub Desktop.
quick scripts to deploy and then wait for completion of a build in aws codedeploy.
if [ -f codedeploy.id ]; then
rm codedeploy.id
fi
aws deploy create-deployment \
--application-name MY_APPLICATION \
--deployment-group-name humans \
--s3-location bucket=MY_BUCKET,bundleType=zip,key=MY_APPLICATION\/$revision.zip \
--output text \
--region us-west-2 > codedeploy.id
zip -r ${BUILD_TIMESTAMP}.zip .
s3cmd put ${BUILD_TIMESTAMP}.zip s3://MY_BUCKET/MY_APPLICATION/
echo "revision=${BUILD_TIMESTAMP}" > codedeploy.properties
rm ${BUILD_TIMESTAMP}.zip
aws deploy get-deployment \
--region us-west-2 \
--deployment-id `cat codedeploy.id` > codedeploy.status
while (grep -q "\"status\": \"Created\"," codedeploy.status || grep -q "\"status\": \"InProgress\"," codedeploy.status)
do
sleep 10
aws deploy get-deployment \
--region us-west-2 \
--deployment-id `cat codedeploy.id` > codedeploy.status
done
if grep -q "\"status\": \"Failed\"," codedeploy.status
then
exit 1
elif grep -q "\"status\": \"Succeeded\"," codedeploy.status
then
exit 0
else
exit 2
fi
@adamgoucher
Copy link
Author

Notes:

  • prepare.sh is kicked off by a JOB_1, and codedeploy.properties is attached to the job as an artifact
  • JOB_2 consumes codedeploy.properties via the environment injection plugin
  • I just run these as 'execute shell'
  • they were tested in DASH (ubuntu)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment