原创

springboot+jenkins+接口自动化测试

89a371fbb9f8488bb9f588bf8452421e-image.png
cf270a1ee9334f8c95c538044024e2b7-image.png
c206be49335b4e0bbca3c5bca450cd86-image.png
执行的shell脚本:

export LANG="zh_CN.utf-8"
cd ${WORKSPACE}
mv -f /home/local/deploy/des-0.0.1-SNAPSHOT.jar /home/local/deploy/des-0.0.1-SNAPSHOT.jar_backup
cp target/des-0.0.1-SNAPSHOT.jar /home/local/deploy/des-0.0.1-SNAPSHOT.jar
sh /home/local/deploy/restart.sh
sleep 5
echo '进行接口自动化测试'
UUID=$(cat /proc/sys/kernel/random/uuid)
result=`curl -s "http://192.168.53.117/atp/api/autoTest?testType=1&moduleId=1&token=ec189a1731d73dfe16d8f9df16d67187&guid=$UUID"`
echo '接口自动化测试结果如下:'
echo $result
res=$(echo $result | grep '"status":"FAIL"')
flag=0
if [[ "$res" != "" ]]
then
    echo "接口自动化测试失败,请查询测试报告!"
    #回滚操作
    echo '回滚操作...'
    cp -f /home/local/deploy/des-0.0.1-SNAPSHOT.jar_backup /home/local/deploy/des-0.0.1-SNAPSHOT.jar
    sh /home/local/deploy/restart.sh
    flag=1
else
    echo "接口自动化测试成功!"
fi
exit $flag

restart.sh

cd /home/local/deploy
ps -ef|grep java|grep des-0.0.1-SNAPSHOT|awk '{print $2}'|xargs kill -9
nohup java -jar des-0.0.1-SNAPSHOT.jar > service.log &
正文到此结束