-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathbuild.sh
executable file
·139 lines (125 loc) · 3.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
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
126
127
128
129
130
131
132
133
134
135
136
137
138
#!/bin/bash
MVN_OPTS="-Duser.home=/var/maven"
if [ ! -e node_modules ]
then
mkdir node_modules
fi
case `uname -s` in
MINGW*)
USER_UID=1000
GROUP_UID=1000
;;
*)
if [ -z ${USER_UID:+x} ]
then
USER_UID=`id -u`
GROUP_GID=`id -g`
fi
esac
init() {
me=`id -u`:`id -g`
echo "DEFAULT_DOCKER_USER=$me" > .env
}
clean () {
docker compose run --rm maven mvn $MVN_OPTS clean
}
install () {
docker compose run --rm maven mvn $MVN_OPTS install -DskipTests
}
test () {
docker compose run --rm maven mvn $MVN_OPTS test
}
buildNode () {
#jenkins
echo "[buildNode] Get branch name from jenkins env..."
BRANCH_NAME=`echo $GIT_BRANCH | sed -e "s|origin/||g"`
if [ "$BRANCH_NAME" = "" ]; then
echo "[buildNode] Get branch name from git..."
BRANCH_NAME=`git branch | sed -n -e "s/^\* \(.*\)/\1/p"`
fi
if [ "$BRANCH_NAME" = "" ]; then
echo "[buildNode] Branch name should not be empty!"
exit -1
fi
if [ "$BRANCH_NAME" = 'master' ]; then
echo "[buildNode] Use entcore version from package.json ($BRANCH_NAME)"
case `uname -s` in
MINGW*)
docker compose run --rm -u "$USER_UID:$GROUP_GID" node sh -c "npm install --no-bin-links && npm update entcore && node_modules/gulp/bin/gulp.js build"
;;
*)
docker compose run --rm -u "$USER_UID:$GROUP_GID" node sh -c "npm install && npm update entcore && node_modules/gulp/bin/gulp.js build"
esac
else
echo "[buildNode] Use entcore tag $BRANCH_NAME"
entcore_tags=$(npm dist-tags ls entcore)
if [[ $entcore_tags == *"$BRANCH_NAME"* ]]; then
case `uname -s` in
MINGW*)
docker compose run --rm -u "$USER_UID:$GROUP_GID" node sh -c "npm install --no-bin-links && npm rm --no-save entcore && npm install --no-save entcore@$BRANCH_NAME && node_modules/gulp/bin/gulp.js build"
;;
*)
docker compose run --rm -u "$USER_UID:$GROUP_GID" node sh -c "npm install && npm rm --no-save entcore && npm install --no-save entcore@$BRANCH_NAME && node_modules/gulp/bin/gulp.js build"
esac
else
case `uname -s` in
MINGW*)
docker compose run --rm -u "$USER_UID:$GROUP_GID" node sh -c "npm install --no-bin-links && node_modules/gulp/bin/gulp.js build"
;;
*)
docker compose run --rm -u "$USER_UID:$GROUP_GID" node sh -c "npm install && node_modules/gulp/bin/gulp.js build"
esac
fi
fi
}
testNode () {
rm -rf coverage
rm -rf */build
case `uname -s` in
MINGW*)
docker compose run --rm -u "$USER_UID:$GROUP_GID" node sh -c "npm install --no-bin-links && node_modules/gulp/bin/gulp.js drop-cache && npm test"
;;
*)
docker compose run --rm -u "$USER_UID:$GROUP_GID" node sh -c "npm install && node_modules/gulp/bin/gulp.js drop-cache && npm test"
esac
}
publish() {
version=`docker compose run --rm maven mvn $MVN_OPTS help:evaluate -Dexpression=project.version -q -DforceStdout`
level=`echo $version | cut -d'-' -f3`
case "$level" in
*SNAPSHOT) export nexusRepository='snapshots' ;;
*) export nexusRepository='releases' ;;
esac
docker compose run --rm maven mvn -DrepositoryId=ode-$nexusRepository -DskipTests --settings /var/maven/.m2/settings.xml deploy
}
for param in "$@"
do
case $param in
init)
init
;;
clean)
clean
;;
buildNode)
buildNode
;;
install)
buildNode && install
;;
publish)
publish
;;
test)
test
;;
testNode)
testNode
;;
*)
echo "Invalid argument : $param"
esac
if [ ! $? -eq 0 ]; then
exit 1
fi
done