【问题标题】:emma code coverage on jenkins is not creating reportsjenkins 上的 emma 代码覆盖率未创建报告
【发布时间】:2014-04-14 11:51:16
【问题描述】:

我正在尝试在 jenkins 上使用 emma 生成代码覆盖率报告,但是它失败了

构建成功。只有 emma 报告失败。

这是我的 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>

这是我的输出

[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

我的jenkins配置如下:

构建

根 POM - pom.xml

目标和选项 - emma:emma

并且我添加了“记录 Emma 覆盖率报告”构建后操作,但它仍然是空的。 我没有在构建后添加存档工件。

【问题讨论】:

    标签: java maven jenkins code-coverage emma


    【解决方案1】:

    我认为您在这里有多个问题。我首先要说的是,您不应该同时使用 Serenity 进行代码覆盖和 Emma,两次增强字节码绝不是一个好主意。请注意,我编写了 Serenity 代码覆盖 Jenkins 插件。

    从异常看来,您使用 root 用户启动了 Tomcat,然后使用另一个用户启动了 Tomcat,而 Jenkins 无法访问它想要访问的目录。可能最好将整个目录 $TOMCAT_INSTALL 和 ~/.jenkins 分配给您要使用的用户。然后再试一次。

    干杯, 迈克尔

    【讨论】:

    • 这已经很老了,我们把所有东西都报废了,改用 Cobertura。我会将您的答案标记为答案,但是我不再有那个环境来测试它。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-05-10
    • 2010-09-08
    • 2014-07-01
    • 2012-03-14
    • 2012-05-08
    相关资源
    最近更新 更多