【发布时间】:2017-10-22 23:18:43
【问题描述】:
我正在努力实现以下目标:
- 作为构建管道的一部分运行一组 Serenity(加上 Cucumber)测试
- 无论所有测试是否通过,都收集报告(显然,它们在失败时特别有用)
- 仅在测试失败的情况下,向贡献者发送电子邮件
- 永远不要因为验收测试失败而导致构建失败,因为此管道用于提交 CI。只有在 Nightly 中的验收测试失败时才会失败。
考虑到所有这些,我开始尝试配置构建:
stage ('Serenity') {
steps {
// For the Delivery CI build don't fail on regression failure
sh 'mvn clean verify -pl regression -DskipCuke=false'
}
post {
always {
publishHTML([allowMissing: true, alwaysLinkToLastBuild: true,
keepAll: true, reportDir: 'regression/target/site/serenity',
reportFiles: 'index.html', reportName: 'Serenity',
reportTitles: ''])
}
failure{
echo 'There are regression suite failures.'
script {
currentBuild.result = 'SUCCESS'
}
emailext attachLog: true, body: 'Find Attached',
compressLog: true, recipientProviders: [[$class:
'CulpritsRecipientProvider']], subject: 'Broken Regression Tests',
to: 'dennis@dennis.ru'
}
}
}
但是它不起作用,因为我无法将 currentBuild.result 的值重置为“SUCCESS”。所以我可以将所有|| true 发送到mvncommand,但这意味着我无法通过电子邮件发送有关损坏的回归测试的信息。
所以我想知道是否有其他人以某种聪明的方式处理过这个问题。我是否需要分配退出代码或其他内容,这是否涉及覆盖 Jenkins 中的默认 shell 参数?
非常感谢任何帮助。
【问题讨论】:
标签: maven jenkins jenkins-pipeline serenity-bdd