-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
·150 lines (133 loc) · 3.82 KB
/
Copy pathbuild.sh
File metadata and controls
executable file
·150 lines (133 loc) · 3.82 KB
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
139
140
141
142
143
144
145
146
147
148
149
#!/bin/bash
MVN_OPTS="-Duser.home=/var/maven -T 4"
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
# If DEBUG env var is set to "true" then set -x to enable debug mode
if [ "$DEBUG" == "true" ]; then
set -x
EDIFICE_CLI_DEBUG_OPTION="--debug"
else
EDIFICE_CLI_DEBUG_OPTION=""
fi
init() {
me=`id -u`:`id -g`
echo "DEFAULT_DOCKER_USER=$me" > .env
# If CLI_VERSION is empty set to latest
if [ -z "$CLI_VERSION" ]; then
CLI_VERSION="latest"
fi
# Create a build.compose.yaml file from following template
cat <<EOF > build.compose.yaml
services:
edifice-cli:
image: opendigitaleducation/edifice-cli:$CLI_VERSION
user: "$DEFAULT_DOCKER_USER"
EOF
# Copy /root/edifice from edifice-cli container to host machine
docker compose -f build.compose.yaml create edifice-cli
docker compose -f build.compose.yaml cp edifice-cli:/root/edifice ./edifice
docker compose -f build.compose.yaml rm -fsv edifice-cli
rm -f build.compose.yaml
chmod +x edifice
./edifice version $EDIFICE_CLI_DEBUG_OPTION
}
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..."
if [ ! -z "$FRONT_BRANCH" ]; then
echo "[buildNode] Get tag name from jenkins param... $FRONT_BRANCH"
BRANCH_NAME="$FRONT_BRANCH"
else
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
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"
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
fi
}
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 $MVN_OPTS -DrepositoryId=ode-$nexusRepository -DskipTests --settings /var/maven/.m2/settings.xml deploy
}
if [ ! -e .env ]; then
init
fi
for param in "$@"
do
case $param in
init)
init
;;
clean)
clean
;;
buildNode)
buildNode
;;
install)
buildNode && install
;;
test)
test
;;
publish)
publish
;;
*)
echo "Invalid argument : $param"
esac
if [ ! $? -eq 0 ]; then
exit 1
fi
done