Created
September 20, 2023 09:53
-
-
Save berg223/282536eb2bd007226daca1711f076b3f to your computer and use it in GitHub Desktop.
bash批量更新代码仓库
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
function showMsg() { | |
echo -e "\033[32m$1\033[0m" | |
} | |
function pull() { | |
if [[ $2 != "--buildOnly" ]] ; then | |
showMsg 'git pull '$1 | |
git pull | |
fi | |
} | |
function build() { | |
if [[ -n $1 ]] && ( [[ $1 == "--build" ]] || [[ $1 == "--buildOnly" ]]); then | |
showMsg 'mvn clean install -DskipTests=true -P dev' | |
mvn clean install -DskipTests=true -P dev | |
fi | |
} | |
function all() { | |
for element in $(ls $1); do | |
dir_or_file=$1"/"$element | |
if [ -d $dir_or_file ]; then | |
cd $1"/"$element | |
pull $element $2 | |
build $2 | |
fi | |
done | |
} | |
# if has param, then use param as path, else tip to input path | |
if [ -n "$1" ]; then | |
all $1 $2 | |
else | |
read -p "请输入git代码仓库存放路径: " path | |
all $path | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment