Search code examples
javamavenjenkinscode-coverageemma

emma code coverage on jenkins is not creating reports


I am trying to generate code coverage reports using emma on jenkins, however it is failing

Builds are successful. It is only the emma reports that are failing.

Here is my pom.xml

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>ThinClientManager</groupId>
    <artifactId>ThinClientManager</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>ThinClientManager</name>
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <included.packages>-Dincluded.packages=hob.tcm</included.packages>
        <included.adapters>-Dincluded.adapters=coverage,complexity,dependency</included.adapters>
    </properties>
    <build>
        <sourceDirectory>src</sourceDirectory>
        <resources>
            <resource>
                <directory>src</directory>
                <excludes>
                    <exclude>**/*.java</exclude>
                </excludes>
            </resource>
        </resources>
        <pluginManagement>
            <plugins>
                <plugin>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>3.1</version>
                    <configuration>
                        <source />
                        <target />
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-surefire-plugin</artifactId>
                    <inherited>true</inherited>
                    <configuration>
                        <forkMode>once</forkMode>
                        <argLine>-javaagent:serenity/serenity.jar -Xms512m -Xmx1024m ${included.packages} ${included.adapters}</argLine>
                    </configuration>
                </plugin>
            </plugins>
        </pluginManagement>
    </build>

    <reporting>
        <plugins>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>emma-maven-plugin</artifactId>
                <version>1.0-alpha-3</version>
                <inherited>true</inherited>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>surefire-report-maven-plugin</artifactId>
                <inherited>true</inherited>
            </plugin>
        </plugins>
    </reporting>


    <repositories>
        <!--other repositories if any -->
        <repository>
            <id>project.local</id>
            <name>project</name>
            <url>file:${project.basedir}/repo</url>
        </repository>
    </repositories>



    <dependencies>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.4</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.example</groupId>
            <artifactId>ant</artifactId>
            <version>1.0</version>
        </dependency>
        <dependency>
            <groupId>com.example</groupId>
            <artifactId>EAAdmin</artifactId>
            <version>1.0</version>
        </dependency>
        <dependency>
            <groupId>com.example</groupId>
            <artifactId>hlset</artifactId>
            <version>1.0</version>
        </dependency>
        <dependency>
            <groupId>com.example</groupId>
            <artifactId>hlsetutil</artifactId>
            <version>1.0</version>
        </dependency>
        <dependency>
            <groupId>com.example</groupId>
            <artifactId>tool</artifactId>
            <version>1.0</version>
        </dependency>
        <dependency>
            <groupId>com.example</groupId>
            <artifactId>xstream</artifactId>
            <version>1.0</version>
        </dependency>
    </dependencies>
</project>

Here is my output

[INFO] Scanning for projects...
[INFO] Searching repository for plugin with prefix: 'emma'.
[INFO] ------------------------------------------------------------------------
[INFO] Building ThinClientManager
[INFO]    task-segment: [emma:emma]
[INFO] ------------------------------------------------------------------------
[INFO] Preparing emma:emma
[INFO] [resources:resources {execution: default-resources}]
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 15 resources
[INFO] [compiler:compile {execution: default-compile}]
[INFO] Nothing to compile - all classes are up to date
[INFO] [emma:instrument {execution: default-instrument}]
[INFO] Instrumenting classes with EMMA
processing instrumentation path ...
ERROR: Could not find local repository for 2.2.1
[INFO] ------------------------------------------------------------------------
[ERROR] FATAL ERROR
[INFO] ------------------------------------------------------------------------
[INFO] com.vladium.emma.EMMARuntimeException
/usr/share/tomcat6/.jenkins/jobs/Workplace Job System (Maven)/workspace/target/generated-classes/emma/classes/hob/props/.svn/prop-base/log.properties.svn-base (Permission denied)
[INFO] ------------------------------------------------------------------------
[INFO] Trace
com.vladium.emma.EMMARuntimeException: com.vladium.emma.EMMARuntimeException
    at com.vladium.emma.instr.InstrProcessorST.handleFile(InstrProcessorST.java:567)
    at com.vladium.util.IPathEnumerator$Factory$PathEnumerator.enumeratePathDir(IPathEnumerator.java:193)
    at com.vladium.util.IPathEnumerator$Factory$PathEnumerator.enumeratePathDir(IPathEnumerator.java:177)
    at com.vladium.util.IPathEnumerator$Factory$PathEnumerator.enumeratePathDir(IPathEnumerator.java:177)
    at com.vladium.util.IPathEnumerator$Factory$PathEnumerator.enumeratePathDir(IPathEnumerator.java:177)
    at com.vladium.util.IPathEnumerator$Factory$PathEnumerator.enumeratePathDir(IPathEnumerator.java:177)
    at com.vladium.util.IPathEnumerator$Factory$PathEnumerator.enumeratePathDir(IPathEnumerator.java:177)
    at com.vladium.util.IPathEnumerator$Factory$PathEnumerator.enumerate(IPathEnumerator.java:97)
    at com.vladium.emma.instr.InstrProcessorST._run(InstrProcessorST.java:715)
    at com.vladium.emma.Processor.run(Processor.java:88)
    at org.codehaus.mojo.emma.task.InstrumentTask.execute(InstrumentTask.java:106)
    at org.codehaus.mojo.emma.EmmaInstrumentMojo.doExecute(EmmaInstrumentMojo.java:158)
    at org.codehaus.mojo.emma.AbstractEmmaMojo.execute(AbstractEmmaMojo.java:98)
    at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:490)
    at hudson.maven.agent.PluginManagerInterceptor.executeMojo(PluginManagerInterceptor.java:182)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:694)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLifecycle(DefaultLifecycleExecutor.java:556)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.forkProjectLifecycle(DefaultLifecycleExecutor.java:1205)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.forkLifecycle(DefaultLifecycleExecutor.java:1038)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:643)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeStandaloneGoal(DefaultLifecycleExecutor.java:569)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:539)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:387)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:348)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:180)
    at org.apache.maven.lifecycle.LifecycleExecutorInterceptor.execute(LifecycleExecutorInterceptor.java:65)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:328)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:138)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:362)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:622)
    at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
    at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
    at hudson.maven.agent.Main.launch(Main.java:205)
    at hudson.maven.MavenBuilder.call(MavenBuilder.java:154)
    at hudson.maven.Maven2Builder.call(Maven2Builder.java:79)
    at hudson.maven.Maven2Builder.call(Maven2Builder.java:55)
    at hudson.remoting.UserRequest.perform(UserRequest.java:118)
    at hudson.remoting.UserRequest.perform(UserRequest.java:48)
    at hudson.remoting.Request$2.run(Request.java:328)
    at hudson.remoting.InterceptingExecutorService$1.call(InterceptingExecutorService.java:72)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
    at java.util.concurrent.FutureTask.run(FutureTask.java:166)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1146)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:701)
Caused by: java.io.FileNotFoundException: /usr/share/tomcat6/.jenkins/jobs/Workplace Job System (Maven)/workspace/target/generated-classes/emma/classes/hob/props/.svn/prop-base/log.properties.svn-base (Permission denied)
    at java.io.RandomAccessFile.open(Native Method)
    at java.io.RandomAccessFile.<init>(RandomAccessFile.java:236)
    at com.vladium.emma.instr.InstrProcessorST.writeFile(InstrProcessorST.java:815)
    at com.vladium.emma.instr.InstrProcessorST$FileWriteJob.run(InstrProcessorST.java:882)
    at com.vladium.emma.instr.InstrProcessorST.drainJobQueue(InstrProcessorST.java:943)
    at com.vladium.emma.instr.InstrProcessorST.addJob(InstrProcessorST.java:929)
    at com.vladium.emma.instr.InstrProcessorST.handleFile(InstrProcessorST.java:562)
    ... 47 more
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 7 seconds
[INFO] Finished at: Mon Apr 14 13:45:41 CEST 2014
[INFO] Final Memory: 21M/50M
[INFO] ------------------------------------------------------------------------
[JENKINS] Archiving /usr/share/tomcat6/.jenkins/jobs/Workplace Job System (Maven)/workspace/pom.xml to ThinClientManager/ThinClientManager/0.0.1-SNAPSHOT/ThinClientManager-0.0.1-SNAPSHOT.pom
channel stopped
Skipping Emma coverage report as mojo did not run.
Finished: FAILURE

My jenkins configuration is as follows:

Build

Root POM - pom.xml

Goals and options - emma:emma

and i have added the "Record Emma Coverage Report" Post-Build Action, however it is still empty. I did not add the archive artifacts post-build action.


Solution

  • I think you have multiple problems here. I'll start by saying that you should not use Serenity for code coverage and Emma at the same time, enhancing the byte code twice is never a good idea. Note that I wrote the Serenity code coverage Jenkins plugin.

    From the exception it looks like you started Tomcat with user root, then with another user, and Jenkins can't access the directories that it wants to. Probably best to chown the entire directory $TOMCAT_INSTALL and ~/.jenkins to the user that you want to use. Then give it another shot.

    Cheers, Michael