diff --git a/jenkins-plugin/src/main/java/org/jenkinsci/plugins/pipeline/maven/publishers/JunitTestsPublisher.java b/jenkins-plugin/src/main/java/org/jenkinsci/plugins/pipeline/maven/publishers/JunitTestsPublisher.java index 35cefdeb..ed760599 100644 --- a/jenkins-plugin/src/main/java/org/jenkinsci/plugins/pipeline/maven/publishers/JunitTestsPublisher.java +++ b/jenkins-plugin/src/main/java/org/jenkinsci/plugins/pipeline/maven/publishers/JunitTestsPublisher.java @@ -305,8 +305,23 @@ private void executeReporter(StepContext context, TaskListener listener, List 0) { - context.setResult(Result.UNSTABLE); + if (testResultAction == null) { + // no unit test results found + if (LOGGER.isLoggable(Level.FINE)) { + listener.getLogger().println("[withMaven] junitPublisher - no unit test results found, ignore"); + } + } else if (testResultAction.getResult().getFailCount() == 0) { + // unit tests are all successful + if (LOGGER.isLoggable(Level.FINE)) { + listener.getLogger().println("[withMaven] junitPublisher - unit tests are all successful"); + } + } else { + if (LOGGER.isLoggable(Level.FINE)) { + listener.getLogger().println("[withMaven] junitPublisher - " + testResultAction.getResult().getFailCount() + " unit test failure(s) found, mark job as unstable"); + } + // TODO: Once JENKINS-43995 lands, update this to set the step status instead of the entire build. + // context.setResult(Result.UNSTABLE); + run.setResult(Result.UNSTABLE); } } catch (Exception e) { listener.error("[withMaven] junitPublisher - Silently ignore exception archiving JUnit results for Maven artifact " + mavenArtifact.toString() + " generated by " + pluginInvocation + ": " + e);