jenkinsci / cobertura-plugin

Jenkins cobertura plugin
https://plugins.jenkins.io/cobertura/
MIT License
109 stars 133 forks source link

Migrate to Supported Coverage Plugin #224

Open jamiejackson opened 5 months ago

jamiejackson commented 5 months ago

Caveat: I have no idea what I'm doing.

Testing done

mvn package (yields a Jenkins version error)

Attempted to migrate from EOL code-coverage-api plugin to coverage-plugin (#219).

Haphazardly bumped/changed some versions in pom.xml and hamfistedly updated a test case.

This is draft because my attempts led to failure:

[ERROR] Failed to execute goal org.jenkins-ci.tools:maven-hpi-plugin:3.49:validate-hpi (default-validate-hpi) on project cobertura: Dependency org.jenkins-ci.plugins.workflow:workflow-job:jar:1400.v7fd111b_ec82f requires Jenkins 2.440 or higher. -> [Help 1]

Notes to self:

### Submitter checklist
- [x](https://emojipedia.org/check-mark-button)] Make sure you are opening from a **topic/feature/bugfix branch** (right side) and not your main branch!
- [x] Ensure that the pull request title represents the desired changelog entry
- [x] Please describe what you did
- [x] Link to relevant issues in GitHub or Jira
- [x] Link to relevant pull requests, esp. upstream and downstream changes
- [x] Ensure you have provided tests - that demonstrates feature works or fixes the issue
jamiejackson commented 5 months ago

BTW, I don't know how to fix the task list.

captain-caveman2k commented 4 months ago

Hi @jamiejackson,

From an outsiders perspective, who is waiting for this plug-in to be updated, I took a look at the build log and can see that the build error is:

[ERROR] Failed to execute goal org.jenkins-ci.tools:maven-hpi-plugin:3.49:validate-hpi (default-validate-hpi) on project cobertura: Dependency org.jenkins-ci.plugins:cloudbees-folder:jar:6.901.vb_4c7a_da_75da_3 requires Jenkins 2.440 or higher. -> [Help 1]

I see from your changes that you have updated the pom to require the Jenkins v2.440 bom. However, I see that the version of Jenkins specified in the pom:L21 is still:

<jenkins.version>2.361.4</jenkins.version>

Just a thought but does this need to be updated as well ?

jamiejackson commented 3 months ago

🤷

I bumped that and a couple of other versions and got:

[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  5.410 s
[INFO] Finished at: 2024-05-16T23:40:23-04:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-enforcer-plugin:3.4.1:enforce (display-info) on project cobertura: 
[ERROR] Rule 5: org.apache.maven.enforcer.rules.dependency.RequireUpperBoundDeps failed with message:
[ERROR] Failed while enforcing RequireUpperBoundDeps. The error(s) are [
[ERROR] Require upper bound dependencies error for io.jenkins.plugins:data-tables-api:1.13.8-4 paths to dependency are:
[ERROR] +-org.jenkins-ci.plugins:cobertura:1.18-SNAPSHOT
[ERROR]   +-io.jenkins.plugins:coverage:1.13.0
[ERROR]     +-io.jenkins.plugins:data-tables-api:1.13.8-4 (managed) <-- io.jenkins.plugins:data-tables-api:2.0.1-1
[ERROR] and
[ERROR] +-org.jenkins-ci.plugins:cobertura:1.18-SNAPSHOT
[ERROR]   +-io.jenkins.plugins:coverage:1.13.0
[ERROR]     +-io.jenkins.plugins:forensics-api:2.4.0 (managed) <-- io.jenkins.plugins:forensics-api:2.4.0
[ERROR]       +-io.jenkins.plugins:data-tables-api:1.13.8-4 (managed) <-- io.jenkins.plugins:data-tables-api:1.13.8-2
[ERROR] ]
[ERROR] -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

I'm done with this, though. I already migrated the pipelines that needed coverage to another CI/CD server that supports it.

captain-caveman2k commented 3 months ago

It seems that the coverage plug-in v1.13, looking at it's pom, requires the data-tables-api v2.0.1-1 and v1.14 requires v2.0.3-1.

What I don't understand, at present, is where the implied data-tables-api v1.13.0-4 is coming from?

Unfortunately, I'm not either a Jenkins plug-in or Java developer. I've been a C and C++ engineer for 30 years, and opensource wise occasionally helping out in curl.

jamiejackson commented 3 months ago

It's a both a dependency and a transitive dependency of the coverage plugin. You can run the mvn dependency:tree task to see the dependency tree.

I think the build error does a pretty decent job of pinpointing the dependencies and version clash, now that I look at it again:

[ERROR] Failed while enforcing RequireUpperBoundDeps. The error(s) are [
[ERROR] Require upper bound dependencies error for io.jenkins.plugins:data-tables-api:1.13.8-4 paths to dependency are:
[ERROR] +-org.jenkins-ci.plugins:cobertura:1.18-SNAPSHOT
[ERROR]   +-io.jenkins.plugins:coverage:1.13.0
[ERROR]     +-io.jenkins.plugins:data-tables-api:1.13.8-4 (managed) <-- io.jenkins.plugins:data-tables-api:2.0.1-1
[ERROR] and
[ERROR] +-org.jenkins-ci.plugins:cobertura:1.18-SNAPSHOT
[ERROR]   +-io.jenkins.plugins:coverage:1.13.0
[ERROR]     +-io.jenkins.plugins:forensics-api:2.4.0 (managed) <-- io.jenkins.plugins:forensics-api:2.4.0
[ERROR]       +-io.jenkins.plugins:data-tables-api:1.13.8-4 (managed) <-- io.jenkins.plugins:data-tables-api:1.13.8-2
[ERROR] ]

coverage wants v2.0 of data-tables-api, but forensics wants v1.13. I don't know how to solve that problem, though.

jgournet commented 3 months ago

I gave a quick try by adding:

    <dependency>
      <groupId>io.jenkins.plugins</groupId>
      <artifactId>data-tables-api</artifactId>
      <version>2.0.3-1</version>
    </dependency>

to force maven to use that version. Good news: that error is gone Bad news: we're now missing quite a few more dependencies, like those:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.11.0:compile (default-compile) on project cobertura: Compilation failure: Compilation failure: 
[ERROR] /mnt/src/main/java/hudson/plugins/cobertura/adapter/CoberturaReportAdapter.java:[5,43] package io.jenkins.plugins.coverage.adapter does not exist
[ERROR] /mnt/src/main/java/hudson/plugins/cobertura/adapter/CoberturaReportAdapter.java:[6,43] package io.jenkins.plugins.coverage.adapter does not exist
[ERROR] /mnt/src/main/java/hudson/plugins/cobertura/adapter/CoberturaReportAdapter.java:[7,48] package io.jenkins.plugins.coverage.adapter.util does not exist
[ERROR] /mnt/src/main/java/hudson/plugins/cobertura/adapter/CoberturaReportAdapter.java:[8,44] package io.jenkins.plugins.coverage.detector does not exist
[ERROR] /mnt/src/main/java/hudson/plugins/cobertura/adapter/CoberturaReportAdapter.java:[20,51] cannot find symbol
[ERROR]   symbol: class JavaXMLCoverageReportAdapter
[ERROR] /mnt/src/main/java/hudson/plugins/cobertura/adapter/CoberturaReportAdapter.java:[46,21] cannot find symbol
[ERROR]   symbol:   class JavaCoverageReportAdapterDescriptor
[ERROR]   location: class hudson.plugins.cobertura.adapter.CoberturaReportAdapter
[ERROR] /mnt/src/main/java/hudson/plugins/cobertura/adapter/CoberturaReportAdapter.java:[47,24] cannot find symbol
[ERROR]   symbol:   class Detectable
[ERROR]   location: class hudson.plugins.cobertura.adapter.CoberturaReportAdapter
[ERROR] /mnt/src/main/java/hudson/plugins/cobertura/IOUtils.java:[8,39] package org.apache.commons.codec.binary does not exist

I tried fighting this, but that's where I'll use @jamiejackson caveat: Caveat: I have no idea what I'm doing.

jamiejackson commented 3 months ago

Some news: https://github.com/jenkinsci/cobertura-plugin/issues/219#issuecomment-2148836714

uhafner commented 2 months ago

This PR does not make sense. The parser for Cobertura is now included in the coverage plugin, making the Cobertura plugin obsolete!

jonesbusy commented 2 months ago

In my opinion the plugin must be marked as deprecated and the repo archived

Like https://plugins.jenkins.io/opencover/ and https://github.com/jenkinsci/opencover-plugin

uhafner commented 2 months ago

In my opinion the plugin must be marked as deprecated and the repo archived

Like https://plugins.jenkins.io/opencover/ and https://github.com/jenkinsci/opencover-plugin

Yes, that would make even more sense, see https://github.com/jenkinsci/cobertura-plugin/issues/226