497
by Curtis Hovey
Added script to update the branches uses by jenkins master |
1 |
#!/bin/bash
|
1054.1.1
by Curtis Hovey
Don't set the group name in cloud-city becaue it is not consistent across all machines, |
2 |
# Update the required resources on the Jenkins master and slaves.
|
3 |
# the --cloud-city option will also update credential and configs.
|
|
497
by Curtis Hovey
Added script to update the branches uses by jenkins master |
4 |
set -eux
|
5 |
||
1470.1.1
by Curtis Hovey
retry windows updated and fail on error. |
6 |
HERE=$(pwd) |
1068.1.2
by Curtis Hovey
create a zip of the local repository and extract it on windows. |
7 |
SCRIPTS=$(readlink -f $(dirname $0)) |
1470.1.1
by Curtis Hovey
retry windows updated and fail on error. |
8 |
REPOSITORY_PARENT=$(dirname $SCRIPTS) |
1068.1.2
by Curtis Hovey
create a zip of the local repository and extract it on windows. |
9 |
|
497
by Curtis Hovey
Added script to update the branches uses by jenkins master |
10 |
MASTER="juju-ci.vapour.ws" |
828
by Curtis Hovey
Fix type and DNS resolution to update master and slaves. |
11 |
SLAVES="precise-slave.vapour.ws trusty-slave.vapour.ws \ |
1242.1.2
by Aaron Bentley
Support xenial. |
12 |
wily-slave.vapour.ws xenial-slave.vapour.ws \
|
1431
by Curtis Hovey
Remove obsolete slave. |
13 |
ppc64el-slave.vapour.ws arm64-slave.vapour.ws \
|
1470.1.1
by Curtis Hovey
retry windows updated and fail on error. |
14 |
kvm-slave.vapour.ws \
|
1257
by Curtis Hovey
update new maas-slaves. |
15 |
munna-maas-slave.vapour.ws silcoon-maas-slave.vapour.ws \
|
825
by Curtis Hovey
Update slaves by their registered hostname. |
16 |
canonistack-slave.vapour.ws juju-core-slave.vapour.ws \
|
1045
by Curtis Hovey
Fix dns name and perms to ensure the right machine us updated. |
17 |
cloud-health-slave.vapour.ws certification-slave.vapour.ws \
|
1391
by Curtis Hovey
Added s390x-slave.vapour.ws to the list of slaves to update. |
18 |
charm-bundle-slave.vapour.ws osx-slave.vapour.ws \
|
1459.1.2
by Curtis Hovey
Include the feature and release slaves in updates. |
19 |
s390x-slave.vapour.ws feature-slave.vapour.ws release-slave.vapour.ws"
|
1068.1.1
by Curtis Hovey
Added support for updating windows slaves. |
20 |
WIN_SLAVES="win-slave.vapour.ws" |
497
by Curtis Hovey
Added script to update the branches uses by jenkins master |
21 |
KEY="staging-juju-rsa" |
731
by Aaron Bentley
Run update-jenkins-branches against juju-ci3. |
22 |
export JUJU_ENV="juju-ci3" |
497
by Curtis Hovey
Added script to update the branches uses by jenkins master |
23 |
|
24 |
update_jenkins() { |
|
825
by Curtis Hovey
Update slaves by their registered hostname. |
25 |
# Get the ip address which will most likely match historic ssh rules.
|
828
by Curtis Hovey
Fix type and DNS resolution to update master and slaves. |
26 |
hostname=$1 |
831
by Curtis Hovey
Use juju-ci's real address when updating slaves. Update path for osx-slave. |
27 |
if [[ $hostname == $MASTER ]]; then |
28 |
# Bypass DNS which points to the apache front-end.
|
|
29 |
host="54.86.142.177" |
|
1255.1.1
by John George
Allow hosts being updated in the .internal domain to be resolved by /etc/hosts. |
30 |
elif [[ $hostname =~ .*[.]internal$ ]]; then |
31 |
host=$hostname # resolved by /etc/hosts |
|
831
by Curtis Hovey
Use juju-ci's real address when updating slaves. Update path for osx-slave. |
32 |
else
|
844
by Curtis Hovey
Use google's DNS to resolve the hosts to update. |
33 |
host=$(host -4 -t A $hostname 8.8.8.8 | tail -1 | cut -d ' ' -f4) |
831
by Curtis Hovey
Use juju-ci's real address when updating slaves. Update path for osx-slave. |
34 |
fi
|
828
by Curtis Hovey
Fix type and DNS resolution to update master and slaves. |
35 |
echo "updating $hostname at $host" |
497
by Curtis Hovey
Added script to update the branches uses by jenkins master |
36 |
if [[ "$CLOUD_CITY" == "true" ]]; then |
37 |
bzr branch lp:~juju-qa/+junk/cloud-city \
|
|
624
by Curtis Hovey
Reliably update cloud-city on master and slaves. |
38 |
bzr+ssh://jenkins@$host/var/lib/jenkins/cloud-city.new
|
497
by Curtis Hovey
Added script to update the branches uses by jenkins master |
39 |
fi
|
40 |
ssh jenkins@$host << EOT |
|
41 |
#!/bin/bash
|
|
831
by Curtis Hovey
Use juju-ci's real address when updating slaves. Update path for osx-slave. |
42 |
export PATH=/usr/local/bin:\$HOME/Bin:\$PATH
|
497
by Curtis Hovey
Added script to update the branches uses by jenkins master |
43 |
set -eux
|
44 |
if [[ "$CLOUD_CITY" == "true" ]]; then
|
|
624
by Curtis Hovey
Reliably update cloud-city on master and slaves. |
45 |
(cd ~/cloud-city; bzr revert; cd -)
|
46 |
bzr pull -d ~/cloud-city ~/cloud-city.new
|
|
47 |
rm -r ~/cloud-city.new
|
|
1054.1.1
by Curtis Hovey
Don't set the group name in cloud-city becaue it is not consistent across all machines, |
48 |
sudo chown -R jenkins ~/cloud-city
|
1042.1.4
by Curtis Hovey
Revise perms. |
49 |
chmod -R go-w ~/cloud-city
|
1042.1.2
by Curtis Hovey
Fix cloud-city perms. |
50 |
chmod 700 ~/cloud-city
|
51 |
chmod 700 ~/cloud-city/gnupg
|
|
1042.1.4
by Curtis Hovey
Revise perms. |
52 |
chmod 600 ~/cloud-city/staging-juju-rsa
|
497
by Curtis Hovey
Added script to update the branches uses by jenkins master |
53 |
fi
|
1018.1.1
by Aaron Bentley
update-branches supports workspace-runner |
54 |
|
55 |
bzr pull -d ~/juju-release-tools
|
|
56 |
bzr pull -d ~/repository
|
|
57 |
bzr pull -d ~/juju-ci-tools
|
|
1023
by Aaron Bentley
Remove errant 'n'. |
58 |
if [[ ! -e ~/workspace-runner ]]; then
|
1021
by Aaron Bentley
Use http URL. |
59 |
bzr branch http://bazaar.launchpad.net/~juju-qa/workspace-runner/trunk/\
|
60 |
~/workspace-runner
|
|
1018.1.1
by Aaron Bentley
update-branches supports workspace-runner |
61 |
fi
|
62 |
bzr pull -d ~/workspace-runner
|
|
825
by Curtis Hovey
Update slaves by their registered hostname. |
63 |
if [[ \$(uname) == "Linux" ]]; then
|
1020
by Aaron Bentley
Do cd before make. |
64 |
cd ~/juju-ci-tools
|
825
by Curtis Hovey
Update slaves by their registered hostname. |
65 |
make install-deps
|
1475.3.6
by Curtis Hovey
Select the requirements file based on platform. |
66 |
elif [[ \$(uname) == "Darwin" ]]; then
|
67 |
~/juju-ci-tools/pipdeps install
|
|
825
by Curtis Hovey
Update slaves by their registered hostname. |
68 |
fi
|
498
by Curtis Hovey
Added support to update ci-drector when it exists. |
69 |
if [[ -d ~/ci-director ]]; then
|
1018.1.1
by Aaron Bentley
update-branches supports workspace-runner |
70 |
bzr pull -d ~/ci-director
|
498
by Curtis Hovey
Added support to update ci-drector when it exists. |
71 |
fi
|
497
by Curtis Hovey
Added script to update the branches uses by jenkins master |
72 |
EOT
|
73 |
}
|
|
74 |
||
75 |
||
1470.1.1
by Curtis Hovey
retry windows updated and fail on error. |
76 |
update_windows() { |
77 |
hostname=$1 |
|
78 |
scp repository.zip Administrator@$hostname:/cygdrive/c/Users/Administrator/
|
|
79 |
ssh Administrator@$hostname << EOT |
|
80 |
bzr pull -d ./juju-release-tools
|
|
81 |
bzr pull -d ./juju-ci-tools
|
|
82 |
/cygdrive/c/progra~2/7-Zip/7z.exe x -y repository.zip
|
|
1484
by Curtis Hovey
Use python to call pipdeps on windows. |
83 |
python ./juju-ci-tools/pipdeps.py install
|
1470.1.1
by Curtis Hovey
retry windows updated and fail on error. |
84 |
EOT
|
85 |
}
|
|
86 |
||
87 |
||
576
by Curtis Hovey
Add support to update the installed packages. |
88 |
CLOUD_CITY="false" |
89 |
while [[ "${1-}" != "" ]]; do |
|
90 |
case $1 in |
|
91 |
--cloud-city)
|
|
92 |
CLOUD_CITY="true" |
|
93 |
;;
|
|
94 |
esac
|
|
95 |
shift
|
|
96 |
done
|
|
97 |
||
651.1.1
by Curtis Hovey
Update all possible hosts, then report which were skipped. |
98 |
SKIPPED="" |
1429
by Curtis Hovey
Use hostname when skipping/updating hosts. |
99 |
for hostname in $MASTER $SLAVES; do |
100 |
update_jenkins $hostname || SKIPPED="$SKIPPED $hostname" |
|
497
by Curtis Hovey
Added script to update the branches uses by jenkins master |
101 |
done
|
1470.1.1
by Curtis Hovey
retry windows updated and fail on error. |
102 |
|
1068.1.1
by Curtis Hovey
Added support for updating windows slaves. |
103 |
# win-slaves have a different user and directory layout tan POSIX hosts.
|
1470.1.1
by Curtis Hovey
retry windows updated and fail on error. |
104 |
# Also, win+bzr does not support symlinks, so we zip the local charm repo.
|
105 |
(cd $REPOSITORY_PARENT; zip -q -r $HERE/repository.zip repository -x *.bzr*) |
|
1429
by Curtis Hovey
Use hostname when skipping/updating hosts. |
106 |
for hostname in $WIN_SLAVES; do |
1470.1.1
by Curtis Hovey
retry windows updated and fail on error. |
107 |
update_windows $hostname || update_windows $hostname |
108 |
if [[ $? -ne 0 ]]; then |
|
109 |
SKIPPED="$SKIPPED $hostname" |
|
110 |
fi
|
|
1068.1.1
by Curtis Hovey
Added support for updating windows slaves. |
111 |
done
|
497
by Curtis Hovey
Added script to update the branches uses by jenkins master |
112 |
|
651.1.1
by Curtis Hovey
Update all possible hosts, then report which were skipped. |
113 |
if [[ -n "$SKIPPED" ]]; then |
651.1.3
by Curtis Hovey
Revised the how machines are skipped to sanely manage set +e. |
114 |
set +x
|
115 |
echo
|
|
738
by Aaron Bentley
Fix speling |
116 |
echo "These hosts were skipped because there was an error" |
651.1.1
by Curtis Hovey
Update all possible hosts, then report which were skipped. |
117 |
echo "$SKIPPED" |
1470.1.1
by Curtis Hovey
retry windows updated and fail on error. |
118 |
exit 1 |
651.1.1
by Curtis Hovey
Update all possible hosts, then report which were skipped. |
119 |
fi
|
1470.1.1
by Curtis Hovey
retry windows updated and fail on error. |
120 |
echo "All hosts updated." |
651.1.1
by Curtis Hovey
Update all possible hosts, then report which were skipped. |
121 |