shell打tag差异包脚本
function convert_compiled_path_2_installed_path(){
if [[ “$f” =~ “target/classes/” ]];then
dst_dir=echo $1 | sed 's/^.*target\//WEB-INF\//'
elif [[ “$1” =~ “script/” ]];then
dst_dir=echo $1 | sed 's/^.*script\//WEB-INF\/classes\/script\//'
elif [[ “$1” =~ “model/” ]];then
dst_dir=echo $1 | sed 's/^.*model\//WEB-INF\/classes\/model\//'
else
echo " - Error: 未知源文件路径 $f"
exit 1
fi
echo $dst_dir
}
PATCH_FILE_NAME=agla-web_patch_8.31.20_$publish_date_req
echo “=== Start to calculate the patch files ======”
#查询差异文件,并将相应文件路径转换为编译后文件路径
git diff $rTag $tTag --name-only | grep -v version.md | grep -v pom.xml | grep -v pomExec.xml| grep -v pomTsf.xml | grep -v .gitignore >patch.log
- java工程
sed -i ‘s/.java$/.class/’ patch.log
sed -i ‘s/src/main/java/target/classes/’ patch.log
sed -i ‘s/src/main/resources/target/classes/’ patch.log
sed -i 's/\s//g’ patch.log
PATCH_FILE_NUM=cat patch.log|wc -l
echo “=== Patch file count: $PATCH_FILE_NUM”
if [ $PATCH_FILE_NUM -eq 0 ];then
echo “no files for pack”
exit 0
fi
cat patch.log | while read f
do
ls $f >/dev/null 2>&1
src_dir=dirname $f
#将编译后文件路径转换为部署后文件路径
dst_dir=convert_compiled_path_2_installed_path $src_dir
echo " - src_file: $f, dst_dir:
d
s
t
d
i
r
"
m
k
d
i
r
−
p
.
.
/
p
a
t
c
h
d
e
v
8
.
31.20
/
dst_dir" mkdir -p ../patch_dev_8.31.20/
dstdir"mkdir−p../patchdev8.31.20/PATCH_FILE_NAME/$dst_dir
cp -u -r
f
.
.
/
p
a
t
c
h
d
e
v
8
.
31.20
/
f ../patch_dev_8.31.20/
f../patchdev8.31.20/PATCH_FILE_NAME/$dst_dir
if [ $? -gt 0 ];then
echo " - Error: Copy failed"
exit 1
fi
done