|
@@ -0,0 +1,90 @@
|
|
|
+#!/bin/bash
|
|
|
+#set -x
|
|
|
+set -e
|
|
|
+
|
|
|
+source_path=/home/www/sync_code/sd_dsl/wms85std
|
|
|
+source_git=(
|
|
|
+ "www@git.yvanui.com:jztd/wms85std.git"
|
|
|
+ "www@git.yvanui.com:lizhiwei/yvan-framework.git"
|
|
|
+ "www@git.yvanui.com:luoyifan/yvan-ui.git"
|
|
|
+)
|
|
|
+source_branch=(
|
|
|
+ "sd_dsl2"
|
|
|
+ "8.6"
|
|
|
+ "master"
|
|
|
+)
|
|
|
+source_position=(
|
|
|
+ "."
|
|
|
+ "yvan-framework"
|
|
|
+ "yvan-ui"
|
|
|
+)
|
|
|
+
|
|
|
+target_path=/home/www/sync_code/sd_dsl/wms85std-sd
|
|
|
+target_git=www@git.yvanui.com:lizhiwei/wms85std-sd.git
|
|
|
+target_branch=master
|
|
|
+target_position=.
|
|
|
+
|
|
|
+echoPrefix="\033[36m+"
|
|
|
+echoSuffix="\033[0m"
|
|
|
+
|
|
|
+# 强制覆盖本地的代码 git fetch --all && git reset --hard origin/master
|
|
|
+pullCode() {
|
|
|
+ # Usage: pullCode "codePath" "gitUrl" "branch" "position"
|
|
|
+ path=$1 # 代码保存路径
|
|
|
+ gitUrl=$2 # git仓库地址
|
|
|
+ branch=${3:-"master"} # git分支
|
|
|
+ position=${4:-""} # 使用“.”clone到当前文件夹
|
|
|
+ # 创建文件夹
|
|
|
+ if [ ! -d "$path" ]; then
|
|
|
+ echo -e "$echoPrefix 请检查服务器是否正确,再执行: mkdir -p $path $echoSuffix"
|
|
|
+ exit
|
|
|
+ fi
|
|
|
+
|
|
|
+ # git clone
|
|
|
+ echo -e "$echoPrefix cd $path $echoSuffix"
|
|
|
+ cd $path
|
|
|
+ if [ "`ls -A $path`" == "" ] || [ ! -d "$path/$position" ] || [ "`ls -A $path/$position`" = "" ]; then
|
|
|
+ echo -e "$echoPrefix git clone $gitUrl $position $echoSuffix"
|
|
|
+ git clone $gitUrl $position
|
|
|
+ fi
|
|
|
+
|
|
|
+ # 进入文件夹,切换分支,git pull
|
|
|
+ if [ "$position" != "" ]; then
|
|
|
+ echo -e "$echoPrefix cd $position $echoSuffix"
|
|
|
+ cd $position
|
|
|
+ fi
|
|
|
+ echo -e "$echoPrefix git checkout $branch $echoSuffix"
|
|
|
+ git checkout $branch
|
|
|
+ echo -e "$echoPrefix git checkout . $echoSuffix"
|
|
|
+ git checkout .
|
|
|
+ echo -e "$echoPrefix git pull $echoSuffix"
|
|
|
+ if [ "`git pull`" == "Already up-to-date." ]; then
|
|
|
+ fi
|
|
|
+ echo ""
|
|
|
+}
|
|
|
+
|
|
|
+source_pull() {
|
|
|
+ for ((idx=0; idx<${#source_git[@]}; idx++)); do
|
|
|
+ pullCode $source_path ${source_git[idx]} ${source_branch[idx]} ${source_position[idx]}
|
|
|
+ done
|
|
|
+}
|
|
|
+
|
|
|
+source_build() {
|
|
|
+ # 构建 java
|
|
|
+ echo -e "$echoPrefix cd $source_path $echoSuffix"
|
|
|
+ cd $source_path
|
|
|
+ chmod +x gradlew
|
|
|
+ echo -e "$echoPrefix gradlew build -x test $echoSuffix"
|
|
|
+ ./gradlew build -x test
|
|
|
+ echo ""
|
|
|
+}
|
|
|
+
|
|
|
+target_pull() {
|
|
|
+ pullCode $target_path ${target_git} ${target_branch} ${target_position}
|
|
|
+}
|
|
|
+
|
|
|
+source_pull
|
|
|
+source_build
|
|
|
+target_pull
|
|
|
+
|
|
|
+# bash <(curl -s http://git.yvanui.com/lizhiwei/jztd-deploy/raw/master/dsl/001sync_code.sh)
|