forked from rcbops/jenkins-build
-
Notifications
You must be signed in to change notification settings - Fork 0
/
jenkins-oz-image-build
executable file
·60 lines (50 loc) · 1.29 KB
/
jenkins-oz-image-build
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
#!/bin/bash
#
# $1 = test repo number
#
# force a local default so this can be run on command line
if [ -z $BUILD_TARGET ]; then
BUILD_TARGET=fedora16_x86_64
fi
[ -e $(dirname $0)/jenkins-deb-common ] || exit 1
. $(dirname $0)/jenkins-deb-common
jenkins_init
jenkins_set_vars
function err_cleanup_oz_image_build() {
# $1 - name
if [ "${NOCLEAN-0}" == "1" ]; then
exit 0
fi
exit 1
}
cd /home/jenkins/workspace/oz-image-build
sudo /sbin/service libvirtd status
SERVICE_STATUS=$?
RES=`sudo /sbin/service libvirtd status | grep -c "Main PID.*killed" || :`
if [ $SERVICE_STATUS -ne 0 -o $RES -ne 0 ]; then
echo "*** WARNING: LIBVIRTD IS DOWN ***"
RAND=$[ ( $RANDOM % 100 ) ]
echo "*** WARNING: sleeping for $RAND seconds before restarting libvirtd ***"
sleep $RAND
sudo /sbin/service libvirtd stop
sudo /sbin/service libvirtd start
echo "*** WARNING: LIBVIRTD restart process completed"
else
echo "*** NOTICE: libvirtd is up and should be running"
fi
set +e
exec 200<$0
RAND=$[ ( $RANDOM % 10 ) + 10 ]
flock -n -e 200
if [ $? -eq 0 ]; then
git reset --hard HEAD
git pull
else
echo "missed the flock - sleeping for $RAND seconds"
sleep $RAND
fi
set -e
if [ "${FORCE-0}" == "1" ]; then
sudo make $BUILD_TARGET-clean
fi
sudo make $BUILD_TARGET