Search code examples
javajenkinsgradlecobertura

Cobertura - classes are not instrumented anymore


I am using the gradle-cobertura-plugin in my Jenkins-build. Yesterday I fixed an issue in this plugin that overwrote the configured auxiliaryClasspath. This issue prevented some classes being present in the coverage report. The fix is something quite simple:

I changed the following:

auxiliaryClasspath = project.files("${project.buildDir.path}/intermediates/classes/${classesDir}")

to

if (auxiliaryClasspath != null) {
        auxiliaryClasspath += project.files("${project.buildDir.path}/intermediates/classes/${classesDir}")
} else {
        auxiliaryClasspath = project.files("${project.buildDir.path}/intermediates/classes/${classesDir}")
}

Running the build locally with gradle cobertura everything works fine and the missing classes showed in the report. After installing the patched version of the plugin on Jenkins the coverage on Jenkins went to zero.

Looking around what happened I found that the classes in the instrumented_classes-folder are not instrumented anymore! Rolling everything back (build.gradle, uninstalling my plugin, clearing the gradle cache, etc.) the behaviour stays the same. As it is working locally I'm wondering what causes this issue.

I assume there is something going awefully wrong that's perhaps logged and silently ignored, but I don't have a clue where to look for this information. The Jenkins logs are clean, so I think adding a logger for the code responsible for instrumenting might help. Unfortunately I don't have any idea what loggers to enable. org.sourceforge.cobertura didn't output anything.

So my question is: Did anybody else see this behaviour and might throw in a clue how to resolve this issue?


Solution

  • OK, I figured it out. After much trial and error I found that a little change in the coverageExcludes-property was the culprit. After changing it several times the classes are instrumented once again. Funny that it did work locally but not on jenkins. I think I have to dive a little bit deeper in this if it occurs again.

    For now I'm happy that it works. :-)