我在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()) } }
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)