您的位置:首页 > 运维架构 > Shell

第一个Shell脚本-lint检查以及报告收集

2015-11-19 16:14 831 查看

作用

在不需要开发修改android项目配置文件的情况下,执行Android lint检查,检查完后,将各个aar包下的检查结果从远程机器copy到节点机器上来。

源码

#!/bin/sh

#用于Android Lint检查项目中,将构建任务中的lint文件copy到当前job中

#从pmo机器中将所有的build文件保存到本地机器上来
#lint文件所在的根目录
work_dir=$1
#需要移动到目标目录
target_dir=$2

echo "lint源目录 : "+$work_dir
echo "lint将要移动到的目录 : "+$target_dir
echo "============================start============="
# 清空结果目录
delete_report_dir(){
if [ ! -d $target_dir/report ];then
mkdir $target_dir/report
fi
for dir2del in $target_dir/report/* ; do
if [ -d $dir2del ]; then
rm -rf $dir2del
fi
done
}
echo "================delete_report_dir_end============"
#移动文件到报告目录
move_dir_lint_file(){
currenDir=$1
for i in `find $currenDir`;do
if [[ "${i##*/}" =~ "lint-results" ]];then
dir_file=$target_dir/report/${currenDir##*/}
# echo "目标存放目录"+$dir_file
# echo "目标文件:" + $i
mkdir -p $dir_file
cp -rf $i $dir_file
fi
done
}
echo "================move_dir_lint_file============"

list_alldir(){
for file2 in `ls -a $work_dir`
do
if [ x"$file2" != x"." -a x"$file2" != x".." ];then
if [ -d "$work_dir/$file2" ];then
echo "$work_dir/$file2"
move_dir_lint_file $work_dir/$file2
fi
fi
done
}
echo "================list_alldir_end============"
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: