获取最后一次构建的构建结果:
curl --user USER:TOKEN
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | #!/bin/bash # author: chunk #通过判断上一次是否构建成功,如果失败则自动清理maven缓存 #rm -rf /var/lib/jenkins/.m2/repository/m2c/ curl http: //10 .0.40.245:8000 /job/ $JOB_NAME /lastBuild/api/xml | grep "<building>ture</building>" if [ $? - eq 0 ]; then echo "last build is ok" else rm -rf $JENKINS_HOME/.m2 /repository/ * echo "clean maven cache is ok" return 0 fi |