我们的项目中有一些不稳定的自动化测试,有时由于超时或其他一些问题而失败,但是我注意到它会自动恢复正常,因此在Jenkinsfile
脚本中有没有一种方法可以让松弛的通道在出现2-3次故障后不继续获取构建失败通知,然后仅在构建返回正常/成功状态时发送通知?
我当时正在考虑为成功和失败包括一个不同的阶段并对其进行迭代?不知道这是否可行,或者它是否正确。
try {
stage('Run Smoke Tests') {
#Test Workers setup & called here
}
echo "BUILD SUCCESS"
stage('Publish Slack Notification') {
slackSend color: '#2ECC71', channel: slackChannel, message: " Production Smoke Tests - Passed! :awesome: \n" +
" List of Enabled Tests : ${Link} \n" +
" Jenkins Test Result : ${jenkinsTestReport}"
}
}
catch (err) {
echo "BUILD FAILURE"
slackSend color: '#FF0000', channel: slackChannel, message: " Production Smoke Tests - Failed! :sadpanda: \n" +
" List of Enabled Tests : ${Link} \n" +
" Jenkins Test Report : ${jenkinsTestReport}"
throw err
}
finally {
cleanWs()
}
}```