static:
SSHFILE="/home/jenkins/.ssh/key"
RUNSERVER=("host")
RUNPATH="/data/web/webapps/ROOT"
v1=$(/usr/local/git/bin/git log|grep commit|awk '{print $2}'|head -n 1|tail -n 1);
v2=$(/usr/local/git/bin/git log|grep commit|awk '{print $2}'|head -n 3|tail -n 1);#m个commit为head -n 3m
filelist=`/usr/local/git/bin/git diff $v1 $v2 --name-only`
for i in $filelist;
do
ends=`echo $i|awk -F '.' '{print $NF}';`
if [ "$ends" == "jsp" ]||[ "$ends" == "xml" ]||[ "$ends" == "css" ]||[ "$ends" == "png" ]||[ "$ends" == "js" ];then
echo "update: "${i#*src/main/webapp};
for service in ${RUNSERVER[@]};
do
scp -i $SSHFILE $i user@$RUNSERVER:$RUNPATH${i#*src/main/webapp};
done
else
echo "cannot update:"$i;
fi
done