-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
executable file
·89 lines (69 loc) · 1.67 KB
/
build.sh
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
#!/bin/bash
PLAY="/opt/play/play"
OUTPUT_WAR_DIR="/tmp/svnadmin"
RELEASE=`cat RELEASE 2> /dev/null`
if [ "$RELEASE" == "" ]; then
RELEASE=1
echo $RELEASE > RELEASE
fi
WAR_FILE="svnadmin##0$RELEASE.war"
function autotest() {
$PLAY auto-test
cd test-result
(
echo "<html><head><title>Test results</title></head><body><ul>"
for i in *.failed.html ; do
if [ -e $i ] ; then
echo "<li><a href="$i">$i</li>"
fi
done
echo "</ul><p><ul>"
for i in *.passed.html ; do
if [ -e $i ] ; then
echo "<li><a href="$i">$i</li>"
fi
done
echo "</ul></body></html>"
) > index.html
if [ -e result.failed ] ; then
exit 1
fi
cd ..
}
function create_war() {
rm -rf war 2> /dev/null
$PLAY war . -o $OUTPUT_WAR_DIR --exclude .svn:.git:war:test:test-result:tmp:eclipse:logs:application.log --%prod
# Add tomcat basic auth in web.xml
cp conf/tomcat-basic-auth-web.xml $OUTPUT_WAR_DIR/WEB-INF/web.xml
# Create war file
cd $OUTPUT_WAR_DIR
zip ../$WAR_FILE -1 -r .
cd -
# Increment release number
expr $RELEASE + 1 > RELEASE
}
function deploy() {
local server=$1
if [ "$server" == "" ]; then
echo "What server?"
exit 1
fi
local release=$2
if [ "$release" == "" ]; then
echo "What release?"
exit 1
fi
local file="svnadmin##0$release.war"
scp $OUTPUT_WAR_DIR/../$file ips@$server:/opt/ips/tomcat7/webapps/
}
case "$1" in
deploy)
echo "deploying..."
deploy $2 $3
;;
*)
echo "building..."
autotest
create_war
;;
esac