-- 終極解析辦法
INSERT INTO `sonarqube`.`ce_queue` (`uuid`, `task_type`, `component_uuid`, `status`, `submitter_login`, `started_at`, `created_at`, `updated_at`) VALUES ('AVYIhJ4YMA7l-90atYoi', 'REPORT', 'AVYIhJ4YMA7l-90atYoi', 'PENDING', 'Administrator', '1469073061961', '1469073061961', '1469073061961');
由於SonarQube5.6
api/ce/submit
接口報以下異常,導致jenkins構建結果顯示為失敗~:
Caused by: java.lang.NullPointerException: null at org.apache.commons.io.IOUtils.copyLarge(IOUtils.java:1792) ~[commons-io-2.4.jar:2.4] at org.apache.commons.io.IOUtils.copyLarge(IOUtils.java:1769) ~[commons-io-2.4.jar:2.4] at org.apache.commons.io.IOUtils.copy(IOUtils.java:1744) ~[commons-io-2.4.jar:2.4] at org.apache.commons.io.FileUtils.copyInputStreamToFile(FileUtils.java:1512) ~[commons-io-2.4.jar:2.4] at org.sonar.ce.queue.report.ReportFiles.save(ReportFiles.java:50) ~[sonar-server-5.6.jar:na]
java.lang.IllegalStateException: Fail to copy report to file: E:\sonarqube-5.6\data\ce\reports\AVYLKumeMA7l-90atYon.zip at org.sonar.ce.queue.report.ReportFiles.save(ReportFiles.java:54) ~[sonar-server-5.6.jar:na] at org.sonar.ce.queue.report.ReportSubmitter.submit(ReportSubmitter.java:79) ~[sonar-server-5.6.jar:na] at org.sonar.server.ce.ws.SubmitAction.handle(SubmitAction.java:86) ~[sonar-server-5.6.jar:na] at org.sonar.server.ws.WebServiceEngine.execute(WebServiceEngine.java:107) ~[sonar-server-5.6.jar:na]
問題是
https://github.com/SonarSource/sonarqube/blob/ee3f830341932b261bfc418d541e0dde49f8acd0/server/sonar-server/src/main/java/org/sonar/ce/queue/report/ReportSubmitter.java
里面的報告上傳失敗,分析其過程是先由scanner把報告壓縮為zip文件,然后通過 api/ce/submit 接口上傳給sonarqube服務器,服務器在ce_quque表中插入一條掛起狀態的后台任務記錄。
於是我跳過這個接口,直接在mysql中插入該記錄,最終正常
<Compile Include="MyFile.cs"> <!-- Exclude the file from analysis --> <SonarQubeExclude>true</SonarQubeExclude> </Compile>
=====================================奇怪的問題==============
http://docs.sonarqube.org/display/SCAN/Excluding+Artifacts+from+the+Analysis
VS中的項目排除代碼分析后,再恢復的時候,sonar-project.properties 文件中仍然不包括該項目?!!
為解決此問題浪費幾個小時。。。看源碼,找文檔(幾乎沒有)。。
后來顯示的設置非測試項目解決問題
<PropertyGroup> <!-- 顯式標記該項目不是測試項目 ,默認是由msbuild scanner自動檢測的--> <SonarQubeTestProject>false</SonarQubeTestProject> </PropertyGroup>