1. 程式人生 > >第一個Shell指令碼-lint檢查以及報告收集

第一個Shell指令碼-lint檢查以及報告收集

作用

在不需要開發修改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============"