jenkinsci / junit-realtime-test-reporter-plugin

Report JUnit test results in real time
https://plugins.jenkins.io/junit-realtime-test-reporter/
MIT License
6 stars 13 forks source link

NPE when surefire report directory is empty #13

Closed brushmate closed 2 years ago

brushmate commented 3 years ago

Version report

Jenkins and plugins versions report:

Jenkins: 2.312
OS: Linux - 5.10.47-linuxkit
---
ace-editor:1.1
analysis-model-api:10.3.0
ansicolor:1.0.0
ant:1.11
antisamy-markup-formatter:2.1
apache-httpcomponents-client-4-api:4.5.13-1.0
authentication-tokens:1.4
badge:1.8
basic-branch-build-strategies:1.3.2
blueocean:1.25.0
blueocean-autofavorite:1.2.4
blueocean-bitbucket-pipeline:1.25.0
blueocean-commons:1.25.0
blueocean-config:1.25.0
blueocean-core-js:1.25.0
blueocean-dashboard:1.25.0
blueocean-display-url:2.4.1
blueocean-events:1.25.0
blueocean-git-pipeline:1.25.0
blueocean-github-pipeline:1.25.0
blueocean-i18n:1.25.0
blueocean-jira:1.25.0
blueocean-jwt:1.25.0
blueocean-personalization:1.25.0
blueocean-pipeline-api-impl:1.25.0
blueocean-pipeline-editor:1.25.0
blueocean-pipeline-scm-api:1.25.0
blueocean-rest:1.25.0
blueocean-rest-impl:1.25.0
blueocean-web:1.25.0
bootstrap4-api:4.6.0-3
bouncycastle-api:2.24
branch-api:2.6.5
build-timestamp:1.0.3
caffeine-api:2.9.2-29.v717aac953ff3
checks-api:1.7.2
cloudbees-bitbucket-branch-source:2.9.11
cloudbees-disk-usage-simple:0.10
cloudbees-folder:6.16
cobertura:1.16
code-coverage-api:1.4.1
command-launcher:1.6
conditional-buildstep:1.4.1
config-file-provider:3.8.1
configuration-as-code:1.53
configuration-as-code-groovy:1.1
credentials:2.6.1
credentials-binding:1.27
dark-theme:0.0.12
data-tables-api:1.10.25-3
display-url-api:2.3.5
docker-commons:1.17
docker-workflow:1.26
durable-task:1.39
echarts-api:5.1.2-11
email-ext:2.83
embeddable-build-status:2.0.3
extended-read-permission:3.2
external-monitor-job:1.7
favorite:2.3.3
font-awesome-api:5.15.4-1
forensics-api:1.3.0
git:4.8.2
git-client:3.9.0
git-parameter:0.9.13
git-server:1.10
github:1.34.1
github-api:1.123
github-branch-source:2.11.2
gravatar:2.2
greenballs:1.15.1
groovy:2.4
handlebars:3.0.8
handy-uri-templates-2-api:2.1.8-1.0
html5-notifier-plugin:1.5
htmlpublisher:1.25
http_request:1.11
hubot-steps:2.0.5
jackson2-api:2.12.4
embeddable-build-status:2.0.3
jacoco:3.3.0
javadoc:1.6
jdk-tool:1.5
jenkins-design-language:1.25.0
jira:3.6
jjwt-api:0.11.2-9.c8b45b8bb173
job-dsl:1.77
jquery:1.12.4-1
jquery-detached:1.2.1
jquery3-api:3.6.0-2
jsch:0.1.55.2
junit:1.53
junit-realtime-test-reporter:0.6
kubernetes:1.30.1
kubernetes-client-api:5.4.1
kubernetes-credentials:0.9.0
ldap:2.7
lockable-resources:2.11
mailer:1.34
matrix-auth:2.6.8
matrix-project:1.19
mattermost:3.1.1
maven-plugin:3.12
mercurial:2.15
metrics:4.0.2.8
momentjs:1.1.1
oic-auth:1.8
okhttp-api:3.14.9
pam-auth:1.6
parameterized-trigger:2.41
pipeline-build-step:2.15
pipeline-graph-analysis:1.11
pipeline-input-step:2.12
pipeline-milestone-step:1.3.2
pipeline-model-api:1.9.1
pipeline-model-definition:1.9.1
pipeline-model-extensions:1.9.1
pipeline-multibranch-defaults:2.1
pipeline-rest-api:2.19
pipeline-stage-step:2.5
pipeline-stage-tags-metadata:1.9.1
pipeline-stage-view:2.19
pipeline-utility-steps:2.10.0
plain-credentials:1.7
plugin-util-api:2.4.0
popper-api:1.16.1-2
prometheus:2.0.10
pubsub-light:1.16
rebuild:1.32
run-condition:1.5
scm-api:2.6.5
script-security:1.78
show-build-parameters:1.0
skip-notifications-trait:1.0.5
snakeyaml-api:1.29.1
sse-gateway:1.24
ssh-agent:1.23
ssh-credentials:1.19
ssh-slaves:1.33.0
structs:1.23
theme-manager:0.6
timestamper:1.13
token-macro:266.v44a80cf277fd
trilead-api:1.0.13
variant:1.4
warnings-ng:9.5.0
windows-slaves:1.8
workflow-aggregator:2.6
workflow-api:2.46
workflow-basic-steps:2.24
workflow-cps:2.94
workflow-cps-global-lib:2.21
workflow-durable-task-step:2.39
workflow-job:2.41
workflow-multibranch:2.26
workflow-scm-step:2.13
workflow-step-api:2.24
workflow-support:3.8
Docker image jenkins/jenkins:2.312-alpine

Reproduction steps

Results

Expected result:

The build succeeds.

Actual result:

The build fails with the following output:

Also:   hudson.remoting.Channel$CallSiteStackTrace: Remote call to JNLP4-connect connection from [...]
        at hudson.remoting.Channel.attachCallSiteStackTrace(Channel.java:1795)
        at hudson.remoting.UserRequest$ExceptionResponse.retrieve(UserRequest.java:356)
        at hudson.remoting.Channel.call(Channel.java:1001)
        at hudson.FilePath.act(FilePath.java:1166)
        at hudson.FilePath.act(FilePath.java:1155)
        at hudson.tasks.junit.JUnitParser.parseResult(JUnitParser.java:107)
        at hudson.tasks.junit.JUnitParser.parseResult(JUnitParser.java:100)
        at org.jenkinsci.plugins.junitrealtimetestreporter.PipelineRealtimeTestResultAction.parse(PipelineRealtimeTestResultAction.java:74)
        at org.jenkinsci.plugins.junitrealtimetestreporter.AbstractRealtimeTestResultAction.getResult(AbstractRealtimeTestResultAction.java:63)
        at org.jenkinsci.plugins.junitrealtimetestreporter.RealtimeJUnitStep$Callback.finished(RealtimeJUnitStep.java:188)
        at org.jenkinsci.plugins.junitrealtimetestreporter.RealtimeJUnitStep$Callback.onSuccess(RealtimeJUnitStep.java:165)
        at org.jenkinsci.plugins.workflow.cps.CpsBodyExecution$SuccessAdapter.receive(CpsBodyExecution.java:377)
        at com.cloudbees.groovy.cps.Outcome.resumeFrom(Outcome.java:73)
        at com.cloudbees.groovy.cps.Continuable$1.call(Continuable.java:166)
        at com.cloudbees.groovy.cps.Continuable$1.call(Continuable.java:163)
        at org.codehaus.groovy.runtime.GroovyCategorySupport$ThreadCategoryInfo.use(GroovyCategorySupport.java:129)
        at org.codehaus.groovy.runtime.GroovyCategorySupport.use(GroovyCategorySupport.java:268)
        at com.cloudbees.groovy.cps.Continuable.run0(Continuable.java:163)
        at org.jenkinsci.plugins.workflow.cps.SandboxContinuable.access$001(SandboxContinuable.java:18)
        at org.jenkinsci.plugins.workflow.cps.SandboxContinuable.run0(SandboxContinuable.java:51)
        at org.jenkinsci.plugins.workflow.cps.CpsThread.runNextChunk(CpsThread.java:185)
        at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.run(CpsThreadGroup.java:400)
        at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.access$400(CpsThreadGroup.java:96)
        at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:312)
        at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:276)
        at org.jenkinsci.plugins.workflow.cps.CpsVmExecutorService$2.call(CpsVmExecutorService.java:67)
        at java.base/java.util.concurrent.FutureTask.run(Unknown Source)
        at hudson.remoting.SingleLaneExecutorService$1.run(SingleLaneExecutorService.java:139)
        at jenkins.util.ContextResettingExecutorService$1.run(ContextResettingExecutorService.java:28)
        at jenkins.security.ImpersonatingExecutorService$1.run(ImpersonatingExecutorService.java:68)
        at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
        at java.base/java.util.concurrent.FutureTask.run(Unknown Source)
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
        at java.base/java.lang.Thread.run(Unknown Source)
java.lang.NullPointerException
    at hudson.tasks.junit.JUnitParser$ParseResultCallable.invoke(JUnitParser.java:150)
    at hudson.FilePath$FileCallableWrapper.call(FilePath.java:3326)
    at hudson.remoting.UserRequest.perform(UserRequest.java:211)
    at hudson.remoting.UserRequest.perform(UserRequest.java:54)
    at hudson.remoting.Request$2.run(Request.java:376)
    at hudson.remoting.InterceptingExecutorService.lambda$wrap$0(InterceptingExecutorService.java:78)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at hudson.remoting.Engine$1.lambda$newThread$0(Engine.java:122)
    at java.lang.Thread.run(Thread.java:748)

This issue has already been reported in https://github.com/jenkinsci/junit-plugin/issues/303, but I think it should be fixed here since the JUnitParser expects a TaskListener since version 1.53 of the junit plug-in, but this plug-in passes null.

I tried to fix it myself, but I don't know where to get the TaskListener from inside the RunAction. If I pass it into the action from the RealtimeJUnitStep store it as a class variable, the tests fail, because the action can not be serialized. Can it be a transient field?

timja commented 2 years ago

StepContext can be serialized, see https://github.com/jenkinsci/junit-realtime-test-reporter-plugin/pull/18