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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
|
#!/bin/bash
set -eux
usage() {
echo "usage: $0 INSTANCE_ID"
echo " INSTANCE_ID: The EC2 intance_id of the windown test machine."
exit 1
}
: ${LOCAL_JENKINS_URL=$JENKINS_URL}
test $# -eq 1 || usage
# Remove previous tarballs and installers from the workspace
rm $WORKSPACE/*
INSTANCE_ID=$1
TARFILE=$(python <<EOT
import json
import sys
import urllib2
build_data = urllib2.urlopen(
'$LOCAL_JENKINS_URL/job/build-revision/lastSuccessfulBuild/api/json')
build_json = json.load(build_data)
for artifact in build_json['artifacts']:
filename = artifact['fileName']
if filename.endswith('.tar.gz'):
break
else:
sys.exit(1)
print filename
EOT
)
ARTIFACT=$LOCAL_JENKINS_URL/job/build-revision/lastSuccessfulBuild/artifact
wget -q $ARTIFACT/$TARFILE
VERSION=$(basename $TARFILE .tar.gz | cut -d '_' -f2)
echo Starting instance $INSTANCE_ID
euca-start-instances $INSTANCE_ID
if [ $? -ne 0 ]; then
exit 1
fi
set +x
instance_ip=''
echo -n Waiting for IP address
while [ -z "$instance_ip" ]; do
sleep 1
instance_ip=$(euca-describe-instances $INSTANCE_ID |
sed '/^INSTANCE/!d' |
cut -f 17)
echo -n .
done
echo
echo Instance has ip $instance_ip
sleep 30
echo -n Waiting for SSH
while ! netcat $instance_ip 22 -w 1 -q 0 </dev/null >/dev/null; do
sleep 1
echo -n .
done
echo
set -x
set +e
CI_DIR="/cygdrive/c/Users/Administrator/ci"
scp -i $JUJU_HOME/staging-juju-rsa \
-o "StrictHostKeyChecking no" -o "UserKnownHostsFile /dev/null" \
$WORKSPACE/$TARFILE $RELEASE_TOOLS/winbuildtest.py \
Administrator@$instance_ip:$CI_DIR/
if [ $? -ne 0 ]; then
exit 1
fi
ssh -i $JUJU_HOME/staging-juju-rsa \
-o "StrictHostKeyChecking no" -o "UserKnownHostsFile /dev/null" \
Administrator@$instance_ip \
'/cygdrive/c/python27/python \\Users\\Administrator\\ci\\winbuildtest.py' \
$TARFILE
if [ $? -ne 0 ]; then
exit 1
fi
scp -i $JUJU_HOME/staging-juju-rsa \
-o "StrictHostKeyChecking no" -o "UserKnownHostsFile /dev/null" \
Administrator@$instance_ip:$CI_DIR/juju-setup-$VERSION.exe $WORKSPACE/
EXIT_STATUS=$?
set -e
euca-stop-instances $INSTANCE_ID
exit $EXIT_STATUS
|