~andrewjbeach/juju-ci-tools/make-local-patcher

« back to all changes in this revision

Viewing changes to build-win-installer

  • Committer: Curtis Hovey
  • Date: 2014-08-12 20:35:41 UTC
  • mto: This revision was merged to the branch mainline in revision 623.
  • Revision ID: curtis@canonical.com-20140812203541-ebdge5usoltynmk1
Strip the /tools dir from from the tools-metadata-url because s3 will return a 404
for a dir.

Show diffs side-by-side

added added

removed removed

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