This repository has been archived by the owner on Jun 27, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
/
build_test.sh
executable file
·126 lines (101 loc) · 3.04 KB
/
build_test.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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
#!/bin/sh
# Builds a test from the test directory.
# Two arguments are required:
# TE_BASE directory
# TEAM Engine deployment directory
# example: ./build_simple_one.sh $TE_BASE tomcat/webapps/teamengine
printHelp(){
echo "Builds a test from the test directory."
echo "Usage build_test.sh TE_BASE TEAM_ENGINE SKIP_TESTS"
echo ""
echo "where:"
echo ""
echo " TE_BASE is the TE_BASE directory"
echo " TEAM_ENGINE is the TEAM_ENGINE directory"
echo " SKIP_TESTS true or false to skip tests while building mvn"
echo ""
echo "More information: https://github.com/opengeospatial/teamengine-builder/"
}
if [ -z "$1" ]; then
echo "[FAIL] Require a directory where TE_BASE is located, as the fist argument."
echo "$moreInfo"
exit 0
else
if [ ! -d "$1" ]; then
echo "[FAIL] Argument 1 '$1' is not a directory. The TE_BASE directory is required."
echo "$moreInfo"
exit 0
fi
fi
if [ -z "$2" ]; then
echo "[FAIL] Require a directory where TEAM Engine has been deployed as a war file, as the second argument."
echo "$moreInfo"
exit 0
else
if [ ! -d "$2" ]; then
echo "[FAIL] Argument 2 '$2' is not a directory."
echo " A directory where TEAM Engine has been deployed as a war file, is required."
echo "$moreInfo"
exit 0
fi
fi
if [ "$3" ]; then
if [ "$3" = "true" ]; then
echo "[INFO] Tests will be skipped when building using -DskipTests"
SKIP="-DskipTests"
else
echo "[WARNING] Third argument was provided, but is not 'true'. Tests will run when building"
fi
else
echo "[INFO] 3rd argument was not provided. Tests will not be skipped."
fi
TE_BASE=$1
TE=$2
dir=$(pwd)
test_name=$(basename $dir)
folder=~/te-build
catalina_base=$folder/catalina_base
#TE_BASE=$catalina_base/TE_BASE
#webapps_lib=$catalina_base/webapps/teamengine/WEB-INF/lib
webapps_lib=$TE/WEB-INF/lib
logfile=log-te-build-test.txt
errorlog=error-log.txt
if [ -f $logfile ]; then
rm $logfile 1> /dev/null 2>&1;
fi
if [ -f $error-log ]; then
rm $error-log
fi
echo "[INFO] Building via MAVEN with this command:' mvn clean install $SKIP '"
mvn clean install $SKIP > $logfile 2>&1
grep "BUILD SUCCESS" $logfile &> /dev/null
if [ $? -ne 0 ]; then
echo "[FAIL] Building of $dir via MAVEN failed."
echo " Details in $logfile."
echo "$test_name" >>error-log
exit 0
else
echo "[INFO] Building of $dir via MAVEN was OK"
fi
cd target
zip_ctl_file=$(ls *ctl.zip | grep -m 1 "ctl")
# get file that has the jars
if ls *deps.zip 1> /dev/null 2>&1; then
zip_dep_file=$(ls *deps.zip | grep -m 1 "deps")
fi
if [ -n "$zip_ctl_file" ]; then
echo '[INFO] Installing' $zip_ctl_file 'at' $TE_BASE/scripts
unzip -q -o $zip_ctl_file -d $TE_BASE/scripts
if [ -n "$zip_dep_file" ]; then
echo '[INFO] Installing' $zip_dep_file 'at' $webapps_lib
unzip -q -o $zip_dep_file -d $webapps_lib
fi
else
echo '[FAIL] zip file not found: ' $zip_ctl_file
exit 0
fi
echo "[SUCCESS] - Built test '$test_name' in $TE_BASE".
echo ""
if [ -f $logfile ]; then
rm $logfile
fi