#!/bin/bash refs=$1 echo ${refs} project=jy_core project_dir=/data/repos/${project} token=d926aee0ab9d2663d03ec8698327c8f131cbc7c43f804f7f635e5db9884c27a1 start_time=$(date '+%s') source /data/tools/jenkins/base.sh CheckoutJob () { cd ${project_dir} git reset --hard git pull git checkout master git pull git fetch git pull --tags branch_tag=`echo ${refs}|awk -F '/' '{print $NF}'` echo $branch_tag git checkout ${branch_tag} CheckBuild echo ${branch_tag} > version.log } if [[ "${refs}" == refs/heads/shd-* ]];then CheckoutJob rsync -avz -e 'ssh -p 22' --exclude={.git,test.conf,.env,doc,docker} ./ shop@shd:/data/wwwroot/shd-jy.vipthink.cn/jy_core/ 1>1 CheckBuild ansible-playbook -vv /etc/ansible/sh_op_jenkins.yml --extra-vars "hosts=sh_dev" -t jy_core-dev CheckStatus elif [[ "${refs}" == refs/tags/sht-* ]];then CheckoutJob echo ${branch_tag} >version.log rsync -avz -e 'ssh -p 22' --exclude={.git,test.conf,.env,doc,docker} ./ shop@sht:/data/wwwroot/sht-jy.vipthink.cn/jy_core/ 1>1 CheckBuild ansible-playbook -vv /etc/ansible/sh_op_jenkins.yml --extra-vars "hosts=sht" -t jy_core-test CheckStatus elif [[ "${refs}" == refs/tags/shp-* ]];then CheckoutJob rsync -avz -e 'ssh -p 22' --exclude={.git,test.conf,.env,doc,docker} ./ shop@shp:/data/wwwroot/shp-jy.vipthink.cn/jy_core/ 1>1 CheckBuild ansible-playbook -vv /etc/ansible/sh_op_jenkins.yml --extra-vars "hosts=sh_gr" -t jy_core-shp CheckStatus elif [[ "${refs}" == refs/tags/sho-* ]];then CheckoutJob rsync -avz -e 'ssh -p 22' --exclude={.git,test.conf,.env,doc,docker} ./ shop@sho:/data/wwwroot/sho-jy.vipthink.cn/jy_core/ 1>1 CheckBuild ansible-playbook -vv /etc/ansible/sh_op_jenkins.yml --extra-vars "hosts=sho" -t jy_core-sho CheckStatus else echo Ignore the build fi