jenkinsci / code-coverage-api-plugin

Deprecated Jenkins Code Coverage Plugin
https://plugins.jenkins.io/code-coverage-api/
MIT License
111 stars 77 forks source link

`java.lang.NullPointerException` after upgrade to 3.3.0 #522

Closed Pesa closed 1 year ago

Pesa commented 1 year ago

Jenkins and plugins versions report

Environment ```text Jenkins: 2.378 OS: Linux - 5.10.0-19-amd64 --- ace-editor:1.1 analysis-model-api:10.20.0 ansicolor:1.0.2 antisamy-markup-formatter:155.v795fb_8702324 apache-httpcomponents-client-4-api:4.5.13-138.v4e7d9a_7b_a_e61 authentication-tokens:1.4 authorize-project:1.4.0 bootstrap5-api:5.2.1-3 bouncycastle-api:2.26 branch-api:2.1051.v9985666b_f6cc build-monitor-plugin:1.13+build.202205140447 build-time-blame:64.vd8f4018a2bbe build-timeout:1.24 caffeine-api:2.9.3-65.v6a_47d0f4d1fe checks-api:1.8.0 cloudbees-folder:6.795.v3e23d3c6f194 cobertura:1.17 code-coverage-api:3.3.0 command-launcher:90.v669d7ccb_7c31 commons-lang3-api:3.12.0-36.vd97de6465d5b_ commons-text-api:1.10.0-27.vb_fa_3896786a_7 conditional-buildstep:1.4.2 configuration-as-code:1569.vb_72405b_80249 credentials:1214.v1de940103927 credentials-binding:523.vd859a_4b_122e6 dark-theme:262.v0202a_4c8fb_6a dashboard-view:2.466.vdfefd95a_b_f8d data-tables-api:1.12.1-4 disk-usage:0.28 display-url-api:2.3.6 docker-commons:1.21 docker-workflow:528.v7c193a_0b_e67c dtkit-api:3.0.2 durable-task:501.ve5d4fc08b0be echarts-api:5.4.0-1 embeddable-build-status:304.vdcf48d6b_d2eb envinject:2.881.v37c62073ff97 envinject-api:1.199.v3ce31253ed13 favorite:2.4.1 font-awesome-api:6.2.0-3 forensics-api:1.16.0 gerrit-trigger:2.37.0 git:4.13.0 git-client:3.13.0 git-forensics:1.11.0 google-login:1.6 gradle:2.1.1 htmlpublisher:1.31 instance-identity:116.vf8f487400980 ionicons-api:31.v4757b_6987003 jackson2-api:2.13.4.20221013-295.v8e29ea_354141 jakarta-activation-api:2.0.1-2 jakarta-mail-api:2.0.1-2 javadoc:226.v71211feb_e7e9 javax-activation-api:1.2.0-5 javax-mail-api:1.6.2-8 jaxb:2.3.7-1 jdk-tool:63.v62d2fd4b_4793 job-dsl:1.81 jquery3-api:3.6.1-2 jsch:0.1.55.61.va_e9ee26616e7 junit:1160.vf1f01a_a_ea_b_7f keyboard-shortcuts-plugin:1.4 mailer:438.v02c7f0a_12fa_4 material-theme:0.5.2-rc100.6121925fe229 matrix-auth:3.1.5 matrix-project:785.v06b_7f47b_c631 maven-plugin:3.20 mina-sshd-api-common:2.9.2-50.va_0e1f42659a_a mina-sshd-api-core:2.9.2-50.va_0e1f42659a_a momentjs:1.1.1 pam-auth:1.10 parameterized-trigger:2.45 percentage-du-node-column:0.1.0 pipeline-build-step:2.18 pipeline-graph-analysis:195.v5812d95a_a_2f9 pipeline-groovy-lib:621.vb_44ce045b_582 pipeline-input-step:456.vd8a_957db_5b_e9 pipeline-milestone-step:101.vd572fef9d926 pipeline-model-api:2.2118.v31fd5b_9944b_5 pipeline-model-definition:2.2118.v31fd5b_9944b_5 pipeline-model-extensions:2.2118.v31fd5b_9944b_5 pipeline-rest-api:2.27 pipeline-stage-step:296.v5f6908f017a_5 pipeline-stage-tags-metadata:2.2118.v31fd5b_9944b_5 pipeline-stage-view:2.27 pipeline-utility-steps:2.14.0 plain-credentials:139.ved2b_9cf7587b plugin-util-api:2.18.0 popper2-api:2.11.6-2 prism-api:1.29.0-1 rebuild:1.34 role-strategy:562.v44e9a_e828d0e run-condition:1.5 scm-api:621.vda_a_b_055e58f7 script-security:1218.v39ca_7f7ed0a_c simple-theme-plugin:136.v23a_15f86c53d snakeyaml-api:1.33-90.v80dcb_3814d35 solarized-theme:0.1 ssh-agent:295.v9ca_a_1c7cc3a_a_ ssh-credentials:305.v8f4381501156 ssh-slaves:2.854.v7fd446b_337c9 sshd:3.249.v2dc2ea_416e33 structs:324.va_f5d6774f3a_d theme-manager:1.5 timestamper:1.21 token-macro:321.vd7cc1f2a_52c8 trilead-api:2.72.v2a_3236754f73 variant:59.vf075fe829ccb warnings-ng:9.20.1 windows-slaves:1.8.1 workflow-aggregator:590.v6a_d052e5a_a_b_5 workflow-api:1200.v8005c684b_a_c6 workflow-basic-steps:994.vd57e3ca_46d24 workflow-cps:3536.vb_8a_6628079d5 workflow-durable-task-step:1217.v38306d8fa_b_5c workflow-job:1254.v3f64639b_11dd workflow-multibranch:716.vc692a_e52371b_ workflow-scm-step:400.v6b_89a_1317c9a_ workflow-step-api:639.v6eca_cd8c04a_a_ workflow-support:839.v35e2736cfd5c xunit:3.1.2 ```

What Operating System are you using (both controller, and any agents involved in the problem)?

Controller: ubuntu 20.04 Agent: ubuntu 22.04

Reproduction steps

Run a code coverage job with the Istanbul reporter.

Expected Results

Job finishes successfully.

Actual Results

[Coverage] Copying painted sources from agent to build folder
[Coverage] -> extracting...
[Coverage] -> done
[Coverage] Deleting source code files of build #364
[Coverage] Finished coverage processing - adding the action to the build...
ERROR: Build step failed with exception
java.lang.NullPointerException
    at java.base/java.util.Objects.requireNonNull(Objects.java:221)
    at io.jenkins.plugins.checks.api.ChecksDetails$ChecksDetailsBuilder.withName(ChecksDetails.java:178)
    at io.jenkins.plugins.coverage.CoverageChecksPublisher.extractChecksDetails(CoverageChecksPublisher.java:69)
    at io.jenkins.plugins.coverage.CoverageChecksPublisher.publishChecks(CoverageChecksPublisher.java:56)
    at io.jenkins.plugins.coverage.CoveragePublisher.perform(CoveragePublisher.java:129)
    at jenkins.tasks.SimpleBuildStep.perform(SimpleBuildStep.java:123)
    at hudson.tasks.BuildStepCompatibilityLayer.perform(BuildStepCompatibilityLayer.java:80)
    at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
    at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:818)
    at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:767)
    at hudson.model.Build$BuildExecution.post2(Build.java:179)
    at hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:711)
    at hudson.model.Run.execute(Run.java:1925)
    at hudson.matrix.MatrixRun.run(MatrixRun.java:153)
    at hudson.model.ResourceController.execute(ResourceController.java:107)
    at hudson.model.Executor.run(Executor.java:449)
Build step 'Publish Coverage Report' marked build as failure

Anything else?

I'm not 100% sure that this is caused by the code-coverage plugin, but I'm sure the NPE was not happening two days ago.

uhafner commented 1 year ago

Thanks for reporting!

We are currently rewriting all parsers from scratch, see https://github.com/uhafner/coverage-model. We did not yet write a parser for Istanbul since there were no existing test cases for this format. Do you have an example report that we can use as setup for such tests?

Pesa commented 1 year ago

Thanks for the quick fix.

We are currently rewriting all parsers from scratch, see https://github.com/uhafner/coverage-model. We did not yet write a parser for Istanbul since there were no existing test cases for this format. Do you have an example report that we can use as setup for such tests?

Actually, we're not using Istanbul directly, our coverage reports are generated in cobertura XML format by gcovr. My understanding is that Istanbul can produce a variety of output formats, cobertura being one of them. We don't care which specific report format is used in jenkins, we employ both gcovr and lcov in our C++ projects, so either LCOV native format or any format supported by gcovr would work for us.

TBH I'm not sure why we're using the Istanbul adapter/parser in jenkins instead of the cobertura one [1]. I tried switching to cobertura in a couple of projects and it seems to work fine, with only a few minor UI differences (e.g., istanbul uses "directory" instead of "package").

[1] Btw, there are two entries labeled "Cobertura" in the "Add" menu, see screenshot below. I believe one of the two is provided by the cobertura plugin but it's impossible to tell them apart and I have no idea what the difference is between the two.

Screenshot Screenshot
uhafner commented 1 year ago

Thanks for the quick fix.

We are currently rewriting all parsers from scratch, see https://github.com/uhafner/coverage-model. We did not yet write a parser for Istanbul since there were no existing test cases for this format. Do you have an example report that we can use as setup for such tests?

Actually, we're not using Istanbul directly, our coverage reports are generated in cobertura XML format by gcovr. My understanding is that Istanbul can produce a variety of output formats, cobertura being one of them. We don't care which specific report format is used in jenkins, we employ both gcovr and lcov in our C++ projects, so either LCOV native format or any format supported by gcovr would work for us.

Ok. Cobertura has been ported already, so your use case should be covered already (it would not hurt to have a file in your format though - if you have one that you are allowed to share it would help to improve our coverage).

TBH I'm not sure why we're using the Istanbul adapter/parser in jenkins instead of the cobertura one [1]. I tried switching to cobertura in a couple of projects and it seems to work fine, with only a few minor UI differences (e.g., istanbul uses "directory" instead of "package").

[1] Btw, there are two entries labeled "Cobertura" in the "Add" menu, see screenshot below. I believe one of the two is provided by the cobertura plugin but it's impossible to tell them apart and I have no idea what the difference is between the two.

Screenshot

The new UI will contain only one Cobertura parser. I don't know why the Cobertura plugin contains a parser for the coverage API plugin, this was a decision made before I started contributing to this plugin. I'm not planning to expose an extension point for new parsers. All of these parsers need to be part of the coverage model now.

Pesa commented 1 year ago

Ok. Cobertura has been ported already, so your use case should be covered already (it would not hurt to have a file in your format though - if you have one that you are allowed to share it would help to improve our coverage).

Sure.

Both files were generated from the same C++ codebase, but don't expect the coverage numbers to match exactly, as the two tools have slightly different heuristics.

Pesa commented 1 year ago

The lcov/info format is described towards the end of the geninfo(1) man page, in case you want to write a parser for it.