我使用maven来构建项目并对代码进行静态分析。 但是,当我在Jenkins工作中运行这些命令时,reuslt是不同的。
本地
$ mvn emma:emma pmd:cpd pmd:pmd javadoc:javadoc
然后我明白了 target \ site
在Jenkins工作中,构建部分,目标和选项
emma:emma pmd:cpd pmd:pmd javadoc:javadoc
运行错误,因为缺少包含报告的target \ site \ emma文件夹。
...
Emma: looking for coverage reports in the entire workspace: /home/jenkins/jenkins-home/workspace/Atlas_Master_Maven
Emma: no coverage files found in workspace. Was any report generated?
Build step 'Record Emma coverage report' changed build result to FAILURE
...
本地是Windows 7 64x,远程Jenkins是CentOS。两者都有maven 3.0.4。
为什么会发生这种情况,以及如何在Jenkins中获得相同的结果?
答案 0 :(得分:1)
仔细查看Jenkins作业输出,我发现Unit测试未执行,因此emma没有数据可以继续。谢谢@eis。是的,没有魔力。
[INFO] --- maven-surefire-plugin:2.10:test (default-test) @ atlas ---
[INFO] Surefire report directory: /home/jenkins/jenkins-home/workspace/Atlas_Master_Maven/target/surefire-reports
-------------------------------------------------------
T E S T S
-------------------------------------------------------
org.apache.maven.surefire.util.SurefireReflectionException: java.lang.reflect.InvocationTargetException; nested exception is java.lang.reflect.InvocationTargetException: null
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:164)
at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:110)
at org.apache.maven.surefire.booter.SurefireStarter.invokeProvider(SurefireStarter.java:175)
at org.apache.maven.surefire.booter.SurefireStarter.runSuitesInProcessWhenForked(SurefireStarter.java:107)
at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:68)
Caused by: java.lang.NoClassDefFoundError: com/funshion/base/service/ServiceException
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2427)
at java.lang.Class.getMethod0(Class.java:2670)
at java.lang.Class.getMethod(Class.java:1603)
at org.apache.maven.surefire.util.ReflectionUtils.tryGetMethod(ReflectionUtils.java:57)
at org.apache.maven.surefire.common.junit3.JUnit3TestChecker.isSuiteOnly(JUnit3TestChecker.java:65)
at org.apache.maven.surefire.common.junit3.JUnit3TestChecker.isValidJUnit3Test(JUnit3TestChecker.java:60)
at org.apache.maven.surefire.common.junit3.JUnit3TestChecker.accept(JUnit3TestChecker.java:55)
at org.apache.maven.surefire.common.junit4.JUnit4TestChecker.accept(JUnit4TestChecker.java:52)
at org.apache.maven.surefire.util.DefaultDirectoryScanner.locateTestClasses(DefaultDirectoryScanner.java:80)
at org.apache.maven.surefire.junit4.JUnit4Provider.scanClassPath(JUnit4Provider.java:174)
at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:83)
... 9 more
Caused by: java.lang.ClassNotFoundException: com.funshion.base.service.ServiceException
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
... 21 more
Results :
Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
mojoSucceeded org.apache.maven.plugins:maven-surefire-plugin:2.10(default-test)
[JENKINS] Recording test results
forkedProjectSucceeded com.funshion.microlens:atlas:1.1.5.BUILD-SNAPSHOT
mojoStarted org.codehaus.mojo:emma-maven-plugin:1.0-alpha-3(default-cli)
[INFO]
[INFO] --- emma-maven-plugin:1.0-alpha-3:emma (default-cli) @ atlas ---
processing input files ...
mojoSucceeded org.codehaus.mojo:emma-maven-plugin:1.0-alpha-3(default-cli)1 file(s) read and merged in 114 ms
nothing to do: no runtime coverage data found in any of the data files