wakaleo/jenkins-the-definitive-guide-book

cobertura tests not found

Opened this issue · 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

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.

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.

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

@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 (wakaleo/game-of-life@66b95ca). But still no luck, and it leaves me with a non-functional build at the end of chapter 2. Any pointers? Thanks!

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

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

<skip>true</skip>

in the surefire plugin seems to fix it.

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.