jenkins-the-definitive-guide-book icon indicating copy to clipboard operation
jenkins-the-definitive-guide-book copied to clipboard

cobertura tests not found

Open headcrashing opened this issue 12 years ago • 7 comments

It seems there is a bug either in the book, the game-of-life project, or Jenkins 1.500. As it is hard to track where the bug is caused for a Jenkins beginner, I am posting it here so you can decide.

When enabling cobertura publishing as described on page 37 of chapter 2, using the recommended default path found in both the book's screenshot and the Jenkins GUI (**/target/site/cobertura/coverage.xml), the result is that the cobertura tests works fine but Jenkins does not find the coverage.xml file.

I checked the workspace and actually the file is not there, but Maven says cobertura actually did process files:

[INFO] --- cobertura-maven-plugin:2.5.2:cobertura (default-cli) @ gameoflife-web --- [INFO] Cobertura 1.9.4.1 - GNU GPL License (NO WARRANTY) - See COPYRIGHT file Cobertura: Loaded information on 2 classes. Report time: 191ms

[INFO] Cobertura Report generation was successful. [INFO] ------------------------------------------------------------------------ [INFO] Reactor Summary: [INFO] [INFO] gameoflife ........................................ SUCCESS [10.518s] [INFO] gameoflife-build .................................. SUCCESS [0.302s] [INFO] gameoflife-core ................................... SUCCESS [1.909s] [INFO] gameoflife-web .................................... SUCCESS [1.780s] [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 15.726s [INFO] Finished at: Mon Feb 04 17:46:31 CET 2013 [INFO] Final Memory: 16M/39M [INFO] ------------------------------------------------------------------------ Veröffentliche Javadocs Zeichne Testergebnisse auf. [Cobertura] Publishing Cobertura coverage report... [Cobertura] No coverage results were found using the pattern '**/target/site/cobertura/coverage.xml' relative to '/usr/share/tomcat6/.jenkins/workspace/gameoflife-default'. Did you enter a pattern relative to the correct directory? Did you generate the XML report(s) for Cobertura? Build step 'Veröffentliche die Cobertura Testabdeckung' changed build result to FAILURE Finished: FAILURE

headcrashing avatar Feb 04 '13 16:02 headcrashing

I am having exactly the same problem. Inspecting the workspace shows that HTML is generated inside gameoflife-core/target/site/cobertura directory, but cobertura.xml is nowhere to be found.

doganov avatar May 03 '13 14:05 doganov

I'm having the same issue. There's no site directory in the top-most target directory in the project's workspace:

[Cobertura] Publishing Cobertura coverage report...
[Cobertura] No coverage results were found using the pattern '**/target/site/cobertura/coverage.xml' relative to 'C:\Program Files (x86)\Jenkins\workspace\gameoflife-default'.  Did you enter a pattern relative to the correct directory?  Did you generate the XML report(s) for Cobertura?
[Cobertura] Skipped cobertura reports.

jallman112 avatar Jul 04 '13 17:07 jallman112

Huh. Several months later, same here. Anybody ever get past this?

ivarley avatar Oct 30 '13 02:10 ivarley

@wakaleo - this seems to be a consistent point of failure in chapter 2. I just spent 2 hours trying to get it to work, with no luck. I tried adding "-Pmetrics" to use the metrics profile, since it seems like you messed with that some about a year ago (https://github.com/wakaleo/game-of-life/commit/66b95ca1136f81d6efe738da0aa59225d3bbf375). But still no luck, and it leaves me with a non-functional build at the end of chapter 2. Any pointers? Thanks!

ivarley avatar Oct 30 '13 03:10 ivarley

There seem to be a couple of issues, with the details provided by the book and with the plugin. Note in the configuration under "Publish Cobertura Coverage Report": Cobertura must be configured to generate XML reports for this plugin to function. I added a format property to the build step and was able to produce the coverage.xml cobertura:cobertura -Dcobertura.report.format=xml

However the report generated 0's across the board, so the build was recorded as unstable. That's where I believe there's a plugin-specific issue, and as far as I've gotten. Let me know if anyone has any insight.

Side note: In v1.8 of the plugin an option was added to mark build as unstable (or not at all) instead of failed when no coverage xml files are found. This allow the build to succeed and you to proceed, depending on whether you prefer to sort out the plugin issue or continue the exercises in the book. The option was added in response to several bug reports: (https://issues.jenkins-ci.org/browse/JENKINS-12640) https://issues.jenkins-ci.org/browse/JENKINS-12857 https://issues.jenkins-ci.org/browse/JENKINS-6554

bellc avatar Nov 07 '13 04:11 bellc

Same problem here with 0's across the board. Deleting the line

<skip>true</skip>

in the surefire plugin seems to fix it.

fliden avatar Mar 09 '15 06:03 fliden

Making @bellc & @fliden's changes fixed this for me. Once I remembered to push the change to my pom.xml file to github.

Figured I'd share my bonehead moment in case it saves someone else the hour I just lost.

CosetteN avatar Mar 15 '16 18:03 CosetteN