如果单元测试失败,Jenkins脚本化管道不会获取测试结果

如果单元测试失败,Jenkins脚本化管道不会获取测试结果,第1张

如果单元测试失败,Jenkins脚本管道不会获取测试结果

我在reddit中得到了答案,功劳归于:/ u / Bodumin

这是根本原因,我在这里引用他:

Move the junit step into the finally. What's likely happening is that testreturns a non 0 (error) status so it fails it of the try.

因此,脚本化管道如下所示:

stage('Test') {        def slackHelper = new com.xyz.jenkins.libraries.SlackNotifier(env)        try { sh "./gradlew test"        } finally { junit 'build/test-results/test/*.xml' AbstractTestResultAction testResultAction =  currentBuild.rawBuild.getAction(AbstractTestResultAction.class) slackHelper.getTestStatuses(currentBuild) slackSend(channel: '#ci-cd', attachments: slackHelper.buildUnitTestSlackNotificationMessage())        }    }


欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/zaji/4945014.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-11-13
下一篇 2022-11-13

发表评论

登录后才能评论

评论列表(0条)

保存