Created
June 22, 2016 13:10
-
-
Save klang/c3518c16a9380380b7caaa905b34ee1b to your computer and use it in GitHub Desktop.
Make jenkins run an aws instance to take care of a build
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
AMI="ami-xxxxxxxx" | |
aws ec2 describe-instances --region eu-central-1 --output table --filter Name=image-id,Values=$AMI | |
aws ec2 run-instances --image-id $AMI --count 1 --instance-type t2.medium --key-name xxxxxx --security-group-ids sg-xxxxxxxx --subnet-id subnet-xxxxxxxx --iam-instance-profile Name=CIWindows --region eu-central-1 --output table | |
aws ec2 wait instance-exists --region eu-central-1 --output json --filter Name=image-id,Values=$AMI | |
instance=$(aws ec2 describe-instances --region eu-central-1 --output text --filter Name=image-id,Values=$AMI --query 'Reservations[*].Instances[*].[InstanceId]') | |
aws ec2 wait instance-status-ok --instance $instance --region eu-central-1 | |
# activate the compile: | |
# insert ssn command here | |
aws ec2 wait instance-terminated --region eu-central-1 --output json --filter Name=image-id,Values=$AMI | |
if [ $? = 255 ] ; then | |
echo "trying again" | |
aws ec2 wait instance-terminated --region eu-central-1 --output json --filter Name=image-id,Values=$AMI | |
if [ $? = 255 ] ; then | |
echo "ok, we tried twice .. we waited 2 x 600 seconds ... now, we give up" | |
fi | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment