当我尝试使用maven分析java程序进行SonarQube 5.6分析时,我无法在仪表板上看到分析结果。我在pom.xml
添加了所有插件和构建步骤,并执行了mvn clean deploy
。
尽管如此,我的构建显示成功,但分析未在SonarQube服务器上发布,而后台任务显示失败(在SonarQube服务器Web UI中)
我的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>com.test.analysis</groupId>
<artifactId>hello.sonar</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>hello.sonar</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<jacoco.version>0.7.9</jacoco.version>
<surefire.version>2.19.1</surefire.version>
<sonar.host.url>http://sonarurl:9000</sonar.host.url>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${surefire.version}</version>
<configuration>
<systemPropertyVariables>
<jacoco-agent.destfile>target/jacoco.exec</jacoco-agent.destfile>
</systemPropertyVariables>
</configuration>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>${jacoco.version}</version>
<executions>
<execution>
<id>default-instrument</id>
<goals>
<goal>instrument</goal>
</goals>
</execution>
<execution>
<id>default-restore-instrumented-classes</id>
<goals>
<goal>restore-instrumented-classes</goal>
</goals>
</execution>
<execution>
<id>default-report</id>
<phase>prepare-package</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.sonarsource.scanner.maven</groupId>
<artifactId>sonar-maven-plugin</artifactId>
<version>3.3.0.603</version>
<executions>
<execution>
<id>sonar</id>
<phase>verify</phase>
<goals>
<goal>sonar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<reporting>
<plugins>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>${jacoco.version}</version>
</plugin>
</plugins>
</reporting>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.jacoco</groupId>
<artifactId>org.jacoco.agent</artifactId>
<version>${jacoco.version}</version>
<classifier>runtime</classifier>
<scope>test</scope>
</dependency>
</dependencies>
</dependencyManagement>
</project>
输出是:
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building sonar.analysis 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- sonar-maven-plugin:3.3.0.603:sonar (default-cli) @ sonar.analysis ---
[INFO] User cache: /root/.sonar/cache
[INFO] Load global repositories
[INFO] Load global repositories (done) | time=128ms
[INFO] Server id: xxxxxxxxx
[INFO] User cache: /root/.sonar/cache
[INFO] Load plugins index
[INFO] Load plugins index (done) | time=2ms
[INFO] SonarQube version: 5.6.6
[INFO] Default locale: "en_US", source code encoding: "UTF-8"
[INFO] Process project properties
[INFO] Load project repositories
[INFO] Load project repositories (done) | time=90ms
[INFO] Load quality profiles
[INFO] Load quality profiles (done) | time=25ms
[INFO] Load active rules
[INFO] Load active rules (done) | time=248ms
[WARNING] SCM provider autodetection failed. No SCM provider claims to support this project. Please use sonar.scm.provider to define SCM of your project.
[INFO] Publish mode
[INFO] ------------- Scan sonar.analysis
[INFO] Load server rules
[INFO] Load server rules (done) | time=62ms
[INFO] Base dir: /root/mvn/sonar.analysis
[INFO] Working dir: /root/mvn/sonar.analysis/target/sonar
[INFO] Source paths: pom.xml, src/main/java
[INFO] Test paths: src/test/java
[INFO] Source encoding: UTF-8, default locale: en_US
[INFO] Index files
[INFO] 2 files indexed
[INFO] Quality profile for java: Sonar way
[INFO] Sensor Lines Sensor
[INFO] Sensor Lines Sensor (done) | time=11ms
[INFO] Sensor JavaSquidSensor
[INFO] Configured Java source version (sonar.java.source): 5
[INFO] JavaClasspath initialization
[WARNING] Bytecode of dependencies was not provided for analysis of source files, you might end up with less precise results. Bytecode can be provided using sonar.java.libraries property
[INFO] JavaClasspath initialization (done) | time=1ms
[INFO] JavaTestClasspath initialization
[INFO] JavaTestClasspath initialization (done) | time=9ms
[INFO] Java Main Files AST scan
[INFO] 1 source files to be analyzed
[INFO] Java Main Files AST scan (done) | time=288ms
[INFO] 1/1 source files have been analyzed
[INFO] Java Test Files AST scan
[INFO] 1 source files to be analyzed
[INFO] 1/1 source files have been analyzed
[INFO] Java Test Files AST scan (done) | time=68ms
[INFO] Sensor JavaSquidSensor (done) | time=747ms
[INFO] Sensor SCM Sensor
[INFO] No SCM system was detected. You can use the 'sonar.scm.provider' property to explicitly specify it.
[INFO] Sensor SCM Sensor (done) | time=0ms
[INFO] Sensor SurefireSensor
[INFO] parsing /root/mvn/sonar.analysis/target/surefire-reports
[INFO] Sensor SurefireSensor (done) | time=1ms
[INFO] Sensor JaCoCoSensor
[INFO] JaCoCoSensor: JaCoCo report not found : /root/mvn/sonar.analysis/target/jacoco.exec
[INFO] Sensor JaCoCoSensor (done) | time=0ms
[INFO] Sensor JaCoCoItSensor
[INFO] JaCoCoItSensor: JaCoCo IT report not found: /root/mvn/sonar.analysis/target/jacoco-it.exec
[INFO] Sensor JaCoCoItSensor (done) | time=0ms
[INFO] Sensor JaCoCoOverallSensor
[INFO] Sensor JaCoCoOverallSensor (done) | time=0ms
[INFO] Sensor XmlFileSensor
[INFO] Sensor XmlFileSensor (done) | time=1ms
[INFO] Sensor Zero Coverage Sensor
[INFO] Sensor Zero Coverage Sensor (done) | time=6ms
[INFO] Sensor Code Colorizer Sensor
[INFO] Sensor Code Colorizer Sensor (done) | time=0ms
[INFO] Sensor CPD Block Indexer
[INFO] JavaCpdBlockIndexer is used for java
[INFO] Sensor CPD Block Indexer (done) | time=19ms
[INFO] Calculating CPD for 0 files
[INFO] CPD calculation finished
[INFO] Analysis report generated in 64ms, dir size=14 KB
[INFO] Analysis reports compressed in 27ms, zip size=8 KB
[INFO] Analysis report uploaded in 34ms
[INFO] ANALYSIS SUCCESSFUL, you can browse http://sonarurl:9000/dashboard/index/com.bbt:sonar.analysis
[INFO] Note that you will be able to access the updated dashboard once the server has processed the submitted analysis report
[INFO] More about the report processing at http://sonarurl:9000/api/ce/task?id=AVzQPhItA
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
Log files
2017.07.03 00:00:15 DEBUG web[c.m.s.j.i.SQLServerStatement] SQLServerStatement:42726 created by (ConnectionID:xxx ClientConnectionId: 6xxx-5xxxxe-4bxxx4-8xxd-4363xxx5)
2017.07.03 00:00:15 DEBUG web[c.m.s.j.i.SQLServerStatement] SQLServerStatement:42726 Executing (not server cursor) SELECT 1
2017.07.03 00:00:15 DEBUG web[c.m.s.j.i.SQLServerResultSet] SQLServerResultSet:43662 created by (SQLServerStatement:42726)
2017.07.03 00:00:15 DEBUG web[c.m.s.j.i.SQLServerStatement] SQLServerPreparedStatement:42727 created by (ConnectionID:xxx ClientConnectionId: 6xxx-xxxe-4bxxx-8xx-4xxxxxxx9xxx5)
2017.07.03 00:00:15 DEBUG web[c.m.s.j.i.SQLServerStatement] SQLServerPreparedStatement:42727: calling sp_prepexec: PreparedHandle:0, SQL:select top (@P0) id, data
from notifications
order by id asc
2017.07.03 00:00:15 DEBUG web[c.m.s.j.i.SQLServerResultSet] SQLServerResultSet:43xx3 created by (SQLServerPreparedStatement:42727)
2017.07.03 00:00:15 DEBUG web[c.m.s.j.i.SQLServerResultSetMetaData] SQLServerResultSetMetaData:24383 created by (SQLServerResultSet:43663)
2017.07.03 00:01:15 DEBUG web[c.m.s.j.i.SQLServerStatement] SQLServerStatement:4xx28 created by (ConnectionID:1557 ClientConnectionId: 6xxxx-xxxe-xxxx-xxxx-xxxxx)
2017.07.03 00:01:15 DEBUG web[c.m.s.j.i.SQLServerStatement] SQLServerStatement:42xx8 Executing (not server cursor) SELECT 1
2017.07.03 00:01:15 DEBUG web[c.m.s.j.i.SQLServerResultSet] SQLServerResultSet:43xx4 created by (SQLServerStatement:42728)
2017.07.03 00:01:15 DEBUG web[c.m.s.j.i.SQLServerStatement] SQLServerPreparedStatement:42xxx9 created by (ConnectionID:1557 ClientConnectionId: 66xxxx4e-4xxxx-8xxx-4363xxxx)
2017.07.03 00:01:15 DEBUG web[c.m.s.j.i.SQLServerStatement] SQLServerPreparedStatement:42729: calling sp_prepexec: PreparedHandle:0, SQL:select top (@P0) id, data
from notifications
order by id asc
2017.07.03 00:01:15 DEBUG web[c.m.s.j.i.SQLServerResultSet] SQLServerResultSet:43665 created by (SQLServerPreparedStatement:42729)
2017.07.03 00:01:15 DEBUG web[c.m.s.j.i.SQLServerResultSetMetaData] SQLServerResultSetMetaData:24384 created by (SQLServerResultSet:43665)
2017.07.03 00:02:15 DEBUG web[c.m.s.j.i.SQLServerStatement] SQLServerStatement:42730 created by (ConnectionID:1557 ClientConnectionId: 6xxxx-5xxxx-4bxxxx-8xxx-43xxxxxx)
2017.07.03 00:02:15 DEBUG web[c.m.s.j.i.SQLServerStatement] SQLServerStatement:42730 Executing (not server cursor) SELECT 1
2017.07.03 00:02:15 DEBUG web[c.m.s.j.i.SQLServerResultSet] SQLServerResultSet:43666 created by (SQLServerStatement:42730)
2017.07.03 00:02:15 DEBUG web[c.m.s.j.i.SQLServerStatement] SQLServerPreparedStatement:42731 created by (ConnectionID:1557 ClientConnectionId: 6xxxx-5xxxx-4bxxxx-8xxx-43xxxxxx)
2017.07.03 00:02:15 DEBUG web[c.m.s.j.i.SQLServerStatement] SQLServerPreparedStatement:42731: calling sp_prepexec: PreparedHandle:0, SQL:select top (@P0) id, data
from notifications
order by id asc
2017.07.03 00:02:15 DEBUG web[c.m.s.j.i.SQLServerResultSet] SQLServerResultSet:43667 created by (SQLServerPreparedStatement:42731)
2017.07.03 00:02:15 DEBUG web[c.m.s.j.i.SQLServerResultSetMetaData] SQLServerResultSetMetaData:24385 created by (SQLServerResultSet:43667)
2017.07.03 00:03:15 DEBUG web[c.m.s.j.i.SQLServerStatement] SQLServerStatement:42732 created by (ConnectionID:1557 ClientConnectionId: 6xxxx-5xxxx-4bxxxx-8xxx-43xxxxxx)
2017.07.03 00:03:15 DEBUG web[c.m.s.j.i.SQLServerStatement] SQLServerStatement:42732 Executing (not server cursor) SELECT 1
2017.07.03 00:03:15 DEBUG web[c.m.s.j.i.SQLServerResultSet] SQLServerResultSet:43668 created by (SQLServerStatement:42732)
2017.07.03 00:03:15 DEBUG web[c.m.s.j.i.SQLServerStatement] SQLServerPreparedStatement:42733 created by (ConnectionID:1557 ClientConnectionId: 6xxxx-5xxxx-4bxxxx-8xxx-43xxxxxx)
2017.07.03 00:03:15 DEBUG web[c.m.s.j.i.SQLServerStatement] SQLServerPreparedStatement:42733: calling sp_prepexec: PreparedHandle:0, SQL:select top (@P0) id, data
from notifications
order by id asc
2017.07.03 00:03:15 DEBUG web[c.m.s.j.i.SQLServerResultSet] SQLServerResultSet:43669 created by (SQLServerPreparedStatement:42733)
2017.07.03 00:03:15 DEBUG web[c.m.s.j.i.SQLServerResultSetMetaData] SQLServerResultSetMetaData:24386 created by (SQLServerResultSet:43669)
2017.07.03 00:03:38 DEBUG web[c.m.s.j.i.SQLServerDriver] Property:serverName Value:servername
2017.07.03 00:03:38 DEBUG web[c.m.s.j.i.SQLServerDriver] Property:portNumber Value:xxx
2017.07.03 00:03:38 DEBUG web[c.m.s.j.i.SQLServerDriver] Property:databaseName Value:Databasename
2017.07.03 00:03:38 DEBUG web[c.m.s.j.i.SQLServerConnection] ConnectionID:1558 created by (SQLServerDriver:1)
2017.07.03 00:03:38 DEBUG web[c.m.s.j.i.SQLServerConnection] ConnectionID:1558 This attempt server name: Database servername port: xxx InstanceName: null useParallel: false
2017.07.03 00:03:38 DEBUG web[c.m.s.j.i.SQLServerConnection] ConnectionID:1558 This attempt endtime: 1499054633746
2017.07.03 00:03:38 DEBUG web[c.m.s.j.i.SQLServerConnection] ConnectionID:1558 This attempt No: 0
2017.07.03 00:03:38 DEBUG web[c.m.s.j.i.SQLServerConnection] ConnectionID:1558 Connecting with server: servername port: 55xx Timeout slice: 15000 Timeout Full: 15
2017.07.03 00:03:38 DEBUG web[c.m.s.j.i.SQLServerConnection] ConnectionID:1558 ClientConnectionId: 9xxx-4xxx-9xx-5c9xxxxx) Server returned major version:12
2017.07.03 00:04:15 DEBUG web[c.m.s.j.i.SQLServerStatement] SQLServerStatement:42734 created by (ConnectionID:1558 ClientConnectionId: 9xxxxxx-8xxxxxx-4xxxxxxx-9xxxx-5xxxxxxxxxxxxxx)
2017.07.03 00:04:15 DEBUG web[c.m.s.j.i.SQLServerStatement] SQLServerStatement:42734 Executing (not server cursor) SELECT 1
2017.07.03 00:04:15 DEBUG web[c.m.s.j.i.SQLServerResultSet] SQLServerResultSet:43670 created by (SQLServerStatement:42734)
2017.07.03 00:04:15 DEBUG web[c.m.s.j.i.SQLServerStatement] SQLServerPreparedStatement:42735 created by (ConnectionID:1558 ClientConnectionId: 9xxxxxx-8xxxxxx-4xxxxxxx-9xxxx-5xxxxxxxxxxxxxx)
2017.07.03 00:04:15 DEBUG web[c.m.s.j.i.SQLServerStatement] SQLServerPreparedStatement:42735: calling sp_prepexec: PreparedHandle:0, SQL:select top (@P0) id, data
from notifications
order by id asc
2017.07.03 00:04:15 DEBUG web[c.m.s.j.i.SQLServerResultSet] SQLServerResultSet:43671 created by (SQLServerPreparedStatement:42735)
2017.07.03 00:04:15 DEBUG web[c.m.s.j.i.SQLServerResultSetMetaData] SQLServerResultSetMetaData:24387 created by (SQLServerResultSet:43671)
2017.07.03 00:04:15 DEBUG web[c.m.s.j.i.SQLServerDatabaseMetaData] SQLServerDatabaseMetaData:1556 created by (ConnectionID:1558 ClientConnectionId: 9xxx-4xxx-9xx-5c9xxxxx)
2017.07.03 00:05:15 DEBUG web[c.m.s.j.i.SQLServerStatement] SQLServerStatement:42736 created by (ConnectionID:1558 ClientConnectionId: 9xxx-4xxx-9xx-5c9xxxxx)
2017.07.03 00:05:15 DEBUG web[c.m.s.j.i.SQLServerStatement] SQLServerStatement:42736 Executing (not server cursor) SELECT 1
2017.07.03 00:05:15 DEBUG web[c.m.s.j.i.SQLServerResultSet] SQLServerResultSet:43672 created by (SQLServerStatement:42736)
2017.07.03 00:05:15 DEBUG web[c.m.s.j.i.SQLServerStatement] SQLServerPreparedStatement:42737 created by (ConnectionID:1558 ClientConnectionId: 9xxx-4xxx-9xx-5c9xxxxx)
2017.07.03 00:05:15 DEBUG web[c.m.s.j.i.SQLServerStatement] SQLServerPreparedStatement:42737: calling sp_prepexec: PreparedHandle:0, SQL:select top (@P0) id, data
from notifications
order by id asc
2017.07.03 00:05:15 DEBUG web[c.m.s.j.i.SQLServerResultSet] SQLServerResultSet:43673 created by (SQLServerPreparedStatement:42737)
2017.07.03 00:05:15 DEBUG web[c.m.s.j.i.SQLServerResultSetMetaData] SQLServerResultSetMetaData:24388 created by (SQLServerResultSet:43673)
2017.07.03 00:06:15 DEBUG web[c.m.s.j.i.SQLServerStatement] SQLServerStatement:42738 created by (ConnectionID:1558 ClientConnectionId: 9xxx-4xxx-9xx-5c9xxxxx)
2017.07.03 00:06:15 DEBUG web[c.m.s.j.i.SQLServerStatement] SQLServerStatement:42738 Executing (not server cursor) SELECT 1
2017.07.03 00:06:15 DEBUG web[c.m.s.j.i.SQLServerResultSet] SQLServerResultSet:43674 created by (SQLServerStatement:42738)
2017.07.03 00:06:15 DEBUG web[c.m.s.j.i.SQLServerStatement] SQLServerPreparedStatement:42739 created by (ConnectionID:1558 ClientConnectionId: 9xxx-4xxx-9xx-5c9xxxxx)
2017.07.03 00:06:15 DEBUG web[c.m.s.j.i.SQLServerStatement] SQLServerPreparedStatement:42739: calling sp_prepexec: PreparedHandle:0, SQL:select top (@P0) id, data
from notifications
order by id asc
2017.07.03 00:06:15 DEBUG web[c.m.s.j.i.SQLServerResultSet] SQLServerResultSet:43675 created by (SQLServerPreparedStatement:42739)
2017.07.03 00:06:15 DEBUG web[c.m.s.j.i.SQLServerResultSetMetaData] SQLServerResultSetMetaData:24389 created by (SQLServerResultSet:43675)
2017.07.03 00:07:15 DEBUG web[c.m.s.j.i.SQLServerStatement] SQLServerStatement:42740 created by (ConnectionID:1558 ClientConnectionId: 9xxx-4xxx-9xx-5c9xxxxx)
2017.07.03 00:07:15 DEBUG web[c.m.s.j.i.SQLServerStatement] SQLServerStatement:42740 Executing (not server cursor) SELECT 1
2017.07.03 00:07:15 DEBUG web[c.m.s.j.i.SQLServerResultSet] SQLServerResultSet:43676 created by (SQLServerStatement:42740)
2017.07.03 00:07:15 DEBUG web[c.m.s.j.i.SQLServerStatement] SQLServerPreparedStatement:42741 created by (ConnectionID:1558 ClientConnectionId: 9xxx-4xxx-9xx-5c9xxxxx)
2017.07.03 00:07:15 DEBUG web[c.m.s.j.i.SQLServerStatement] SQLServerPreparedStatement:42741: calling sp_prepexec: PreparedHandle:0, SQL:select top (@P0) id, data
from notifications
order by id asc
2017.07.03 00:07:15 DEBUG web[c.m.s.j.i.SQLServerResultSet] SQLServerResultSet:43677 created by (SQLServerPreparedStatement:42741)
2017.07.03 00:07:15 DEBUG web[c.m.s.j.i.SQLServerResultSetMetaData] SQLServerResultSetMetaData:24390 created by (SQLServerResultSet:43677)
2017.07.03 00:08:15 DEBUG web[c.m.s.j.i.SQLServerStatement] SQLServerStatement:42742 created by (ConnectionID:1558 ClientConnectionId: 9xxx-4xxx-9xx-5c9xxxxx)
2017.07.03 00:08:15 DEBUG web[c.m.s.j.i.SQLServerStatement] SQLServerStatement:42742 Executing (not server cursor) SELECT 1
2017.07.03 00:08:15 DEBUG web[c.m.s.j.i.SQLServerResultSet] SQLServerResultSet:43678 created by (SQLServerStatement:42742)
2017.07.03 00:08:15 DEBUG web[c.m.s.j.i.SQLServerStatement] SQLServerPreparedStatement:42743 created by (ConnectionID:1558 ClientConnectionId: 9xxx-4xxx-9xx-5c9xxxxx)
2017.07.03 00:08:15 DEBUG web[c.m.s.j.i.SQLServerStatement] SQLServerPreparedStatement:42743: calling sp_prepexec: PreparedHandle:0, SQL:select top (@P0) id, data
from notifications
order by id asc