我希望声纳能够使用jacoco代码覆盖率报告显示项目的代码质量。我可以使用jacoco生成代码覆盖率报告,也可以使用可执行文件jacoco-ut.exec进行单元测试。当我使用詹金斯时,我会得到以下消息。
我在项目中使用旧的目标文件夹,因此构建成功
enter code here
[INFO] --- maven-compiler-plugin:2.0.2:compile (default-compile) @ ProjectX ---
[INFO] No sources to compile
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ ProjectX ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory C:\Program Files (x86)\Jenkins\workspace\13april-ty3\src\test\resources
[INFO]
[INFO] --- maven-compiler-plugin:2.0.2:testCompile (default-testCompile) @ ProjectX ---
[INFO] No sources to compile
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ ProjectX ---
[INFO] No tests to run.
[JENKINS] Recording test results
[INFO]
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ ProjectX ---
[WARNING] JAR will be empty - no content was marked for inclusion!
[INFO] Building jar: C:\Program Files (x86)\Jenkins\workspace\13april-ty3\target\ProjectX-0.0.1-SNAPSHOT.jar
[INFO]
[INFO] --- jacoco-maven-plugin:0.5.5.201112152213:report (jacoco-site) @ ProjectX ---
[ERROR] Unable to read execution data file C:\Program Files (x86)\Jenkins\workspace\13april-ty3\target\coverage-reports\jacoco-unit.exec: C:\Program Files (x86)\Jenkins\workspace\13april-ty3\target\coverage-reports\jacoco-unit.exec (The system cannot find the path specified)
java.io.FileNotFoundException: C:\Program Files (x86)\Jenkins\workspace\13april-ty3\target\coverage-reports\jacoco-unit.exec (The system cannot find the path specified)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(FileInputStream.java:146)
at org.jacoco.maven.ReportMojo.loadExecutionData(ReportMojo.java:101)
at org.jacoco.maven.ReportMojo.executeMojo(ReportMojo.java:78)
at org.jacoco.maven.AbstractJacocoMojo.execute(AbstractJacocoMojo.java:66)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:132)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:120)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:347)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:154)
at org.jvnet.hudson.maven3.launcher.Maven31Launcher.main(Maven31Launcher.java:132)
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:606)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchStandard(Launcher.java:330)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:238)
at jenkins.maven3.agent.Maven31Main.launch(Maven31Main.java:181)
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:606)
at hudson.maven.Maven3Builder.call(Maven3Builder.java:136)
at hudson.maven.Maven3Builder.call(Maven3Builder.java:71)
at hudson.remoting.UserRequest.perform(UserRequest.java:121)
at hudson.remoting.UserRequest.perform(UserRequest.java:49)
at hudson.remoting.Request$2.run(Request.java:324)
at hudson.remoting.InterceptingExecutorService$1.call(InterceptingExecutorService.java:68)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
[INFO]
[INFO] --- maven-install-plugin:2.4:install (default-install) @ ProjectX ---
[INFO] Installing C:\Program Files (x86)\Jenkins\workspace\13april-ty3\target\ProjectX-0.0.1-SNAPSHOT.jar to C:\.m2\repository\com\company\inner\ProjectX\0.0.1-SNAPSHOT\ProjectX0.0.1-SNAPSHOT.jar
[INFO] Installing C:\Program Files (x86)\Jenkins\workspace\13april-ty3\pom.xml to C:\.m2\repository\com\company\inner\ProjectX\0.0.1-SNAPSHOT\ProjectX-0.0.1-SNAPSHOT.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4.266 s
[INFO] Finished at: 2015-04-13T17:55:41+00:00
[INFO] Final Memory: 18M/183M
[INFO] ------------------------------------------------------------------------
Waiting for Jenkins to finish collecting data
[JENKINS] Archiving C:\Program Files (x86)\Jenkins\workspace\13april-ty3\pom.xml to com.company.inner/ProjectX/0.0.1-SNAPSHOT/ProjectX-0.0.1-SNAPSHOT.pom
[JENKINS] Archiving C:\Program Files (x86)\Jenkins\workspace\13april-ty3\target\ProjectX-0.0.1-SNAPSHOT.jar to com.company.inner/ProjectX/0.0.1-SNAPSHOT/ProjectX-0.0.1-SNAPSHOT.jar
channel stopped
[JaCoCo plugin] Collecting JaCoCo coverage data...
[JaCoCo plugin] **/**.exec;**/classes;**/src/main/java; locations are configured
[JaCoCo plugin] Number of found exec files for pattern **/**.exec: 2
[JaCoCo plugin] Saving matched execfiles: C:\Program Files (x86)\Jenkins\workspace\13april-ty3\ProjectX-y\target\coverage-reports\jacoco-unit.exec C:\Program Files (x86)\Jenkins\workspace\13april-ty3\ProjectX\target\coverage-reports\jacoco-unit.exec
[JaCoCo plugin] Saving matched class directories for class-pattern: **/classes: C:\Program Files (x86)\Jenkins\workspace\13april-ty3\ProjectX-y\target\classes C:\Program Files (x86)\Jenkins\workspace\13april-ty3\ProjectX\bin\target\classes C:\Program Files (x86)\Jenkins\workspace\13april-ty3\ProjectX\target\classes C:\Program Files (x86)\Jenkins\workspace\13april-ty3\ProjectX\target\classes
[JaCoCo plugin] Saving matched source directories for source-pattern: **/src/main/java: C:\Program Files (x86)\Jenkins\workspace\13april-ty3\ProjextX-y\src\main\java C:\Program Files (x86)\Jenkins\workspace\13april-ty3\ProjectX\src\main\java C:\Program Files (x86)\Jenkins\workspace\13april-ty3\ProjectX\src\main\java
[JaCoCo plugin] Loading inclusions files..
[JaCoCo plugin] inclusions: []
[JaCoCo plugin] exclusions: []
[JaCoCo plugin] Thresholds: JacocoHealthReportThresholds [minClass=0, maxClass=0, minMethod=0, maxMethod=0, minLine=0, maxLine=0, minBranch=0, maxBranch=0, minInstruction=0, maxInstruction=0, minComplexity=0, maxComplexity=0]
[JaCoCo plugin] Publishing the results..
[JaCoCo plugin] Loading packages..
[JaCoCo plugin] Done.
[13april-ty3] $ "C:\Program Files\apache-maven-3.2.2\bin\mvn.bat" -f "C:\Program Files (x86)\Jenkins\workspace\13april-ty3\pom.xml" -e -B sonar:sonar -Dsonar.sources=ProjectX/src -Dsonar.language=java -Dsonar.core.codeCoveragePlugin=jacoco -Dsonar.jacoco.reportPath=ProjectX/target/coverage-reports/jacoco-unit.exec-Dsonar.dynamicAnalysis=reuseReports -Dsonar.surefire.reportsPath=target/surefire-reports -Dsonar.jdbc.driver=com.mysql.jdbc.Driver "-Dsonar.jdbc.url=jdbc:mysql://localhost:3306/sonar?useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true&useConfigs=maxPerformance" ******** ******** -Dsonar.host.url=http://localhost:9000 ******** ********
答案 0 :(得分:0)
参见声纳:maven中的声纳。 http://mojo.codehaus.org/sonar-maven-plugin/plugin-info.html
和
在pom(或全局级别.xml)中配置各种声纳。。属性,或使用-Dsonar将它们传递给maven。。 = value。
例如:
sonar.scm.url=scm\:svn\:http\://svnserver/ProjectCore/ProjectName/trunk
sonar.tests=test/java,src/java-test
sonar.jdbc.username=sonar
sonar.sources=src/java
sonar.libraries=target/lib/*.jar
sonar.junit.reportsPath=targettest-results
sonar.build-stability.url=jenkins\:http\://10.112.116.254\:9040//job/ProjectName
sonar.jdbc.driverClassName=org.h2.Driver
sonar.host.url=http\://sonarOrsomeserver.company.com\:9000
sonar.java.source=1.7
sonar.working.directory=/production/home/user113/JSlaves/someslaveserver1_1/workspace/ProjectName/build/sonar
sonar.jacoco.itReportPath=target/jacoco/IT/jacocoIT.exec
sonar.java.binaries=build/classes/main
sonar.projectVersion=2.3.0
sonar.java.target=1.7
sonar.surefire.reportsPath=target/test-results
sonar.environment.information.key=Maven
sonar.projectName=ProjectName
sonar.binaries=build/classes/main
sonar.jacoco.reportPath=target/jacoco/UT/jacocoUT.exec
sonar.projectKey=com.company.productclass\:ProjectName
sonar.dynamicAnalysis=reuseReports
sonar.jdbc.url=jdbc\:h2\:tcp\://sonarOrsomeserver.company.com\:9092/sonar
sonar.jdbc.password=sonar
sonar.projectBaseDir=/production/home/user113/JSlaves/someslave1_1/workspace/ProjectName