使用捕获异常的方法来实现这一步!
stage('单元测试') {
steps {
echo "starting unitTest......"
script {
try {
checkout scm
def gradlePATH = "/var/jenkins_home/tools/hudson.plugins.gradle.GradleInstallation/gradle3.5"
dir(env.JOB_NAME){
sh "cp ${WORKSPACE}/${k8sPath}/Jenkinsfile ."
sh "${gradlePATH}/bin/gradle clean build -x test "
}
}
catch (err){
echo "gradle构建出错了,请您检查错误信息"
exit 1
}
}
}
网友评论