-
Notifications
You must be signed in to change notification settings - Fork 11
/
jenkins_build.sh
117 lines (97 loc) · 1.97 KB
/
jenkins_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
#!/bin/sh
#复制文件
copyFile(){
local src=$1
local dir=$2
local name=$3
if [ ! -d $dir ]
then
mkdir -p $dir
fi
cp "$src" "$dir/$name"
}
#检查数组包含
containStr(){
arr=$1
for str in ${arr[@]}
do
if [ "$str" = "$2" ]
then
return 1
fi
done
return 0
}
# 编译
build(){
local src=$1
echo "build $src"
cd $WORKPATH/$src && sh build.sh
echo "build $src 完成"
}
# TODO 添加版本号 数据库
# 可以编译的列表,用来检验参数
buildList=("account" "center" "charge_server" "cross" "game" "logserver" "gm" "coupon_server" "trade_server")
# 工作目录
WORKPATH=$(pwd)
echo "当前目录$WORKPATH"
# 发布路径
buildPath="build"
# 需要编译的
needBuildList=()
if [ "$2" = "all" ];
then
needBuildList=(${buildList[@]})
else
needBuildList=($@)
needBuildList=(${needBuildList[@]:1})
fi
# 检查参数
for needBuild in "${needBuildList[@]}"
do
containStr "${buildList[*]}" $needBuild
ret=$?
if [ $ret -eq 0 ];
then
echo "输入参数[$needBuild]错误,不能构建"
exit 1
fi
done
# 编译
for needBuild in "${needBuildList[@]}"
do
build $needBuild
done
echo "发布路径:$WORKPATH/$buildPath"
# 复制二进制文件
for needBuild in "${needBuildList[@]}"
do
echo "复制$needBuild服"
copyFile "$WORKPATH/$needBuild/main" "$WORKPATH/$buildPath/$needBuild" $needBuild
echo "复制$needBuild服完成"
done
mapDir="$WORKPATH/$buildPath/resources/map"
templateDir="$WORKPATH/$buildPath/resources/template"
# 复制数据
echo "复制策划数据"
if [ ! -d $mapDir ]
then
mkdir -p $mapDir
fi
# 复制地图数据
cd "$WORKPATH/resources/map"
for f in *.txt
do
cp -rf "$f" "$mapDir/"
done
# 复制模板数据
if [ ! -d $templateDir ]
then
mkdir -p $templateDir
fi
cd "$WORKPATH/resources/template"
for f in *.json
do
cp -rf "$f" "$templateDir/"
done
echo "复制策划数据完成"