簡體   English   中英

Maven Sonarqube 插件:無法執行 SonarQube:無法從服務器獲取引導索引

[英]Maven Sonarqube plugin: Unable to execute SonarQube: Fail to get bootstrap index from server

我在為一個項目設置 sonarqube maven 插件時頭疼。

所以我有一個 sonarqube 實例,比如說https://sonarqube.mycompany.software 我在這個實例上測試了許多項目,幾個月以來它運行良好。 我還有其他使用 maven 插件的項目(但使用另一個 docker 圖像運行)

我開始一個新項目,當然我想添加到我的自動管道中,用 sonarqube 檢查代碼。

當我使用 OpenJdk-8 在我的機器上執行 maven 插件時,一切都運行良好:

$ mvn org.jacoco:jacoco-maven-plugin:0.8.5:prepare-agent clean test package
$ mvn sonar:sonar -Dsonar.projectKey=projectname -Dsonar.host.url=https://sonarqube.mycompany.software -Dsonar.login=youwishyouknew
[... Lots of output ...]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  16.891 s
[INFO] Finished at: 2020-05-07T18:03:00+02:00
[INFO] ------------------------------------------------------------------------

然后我嘗試使用maven:3.6.3-jdk-8圖像在服務器(管道將運行的位置)上執行與 docker 完全相同的命令,我收到此錯誤:

$ docker run -v `pwd`/m2cache:/root/.m2 -v `pwd`/sonarcache:/root/.sonar/cache -v`pwd`:`pwd` -w`pwd` maven:3.6.3-jdk-8  mvn sonar:sonar -Dsonar.projectKey=projectname -Dsonar.host.url=https://sonarqube.mycompany.software -Dsonar.login=youwishyouknew

[INFO] 
[INFO] ---------------------------< software.mycompany:projectname >----------------------------
[INFO] Building projectname 2.3.0
[INFO] --------------------------------[ war ]---------------------------------
[INFO] 
[INFO] --- sonar-maven-plugin:3.7.0.1746:sonar (default-cli) @ projectname ---
[INFO] User cache: /root/.sonar/cache
[ERROR] SonarQube server [https://sonarqube.mycompany.software] can not be reached
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  2.286 s
[INFO] Finished at: 2020-05-07T16:06:22Z
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.7.0.1746:sonar (default-cli) on project projectname: Unable to execute SonarQube: Fail to get bootstrap index from server: Broken pipe (Write failed) -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

當我執行此操作時,Sonarqube 日志中絕對沒有發生任何事情(任何日志中都沒有任何移動,而當我在我的機器上運行它時,我發現了我期望找到的所有內容。)

此外,如果我嘗試從curl圖像 sonarqube 服務器 curl sonarqube 服務器,它工作! 也試過ping

$ docker run -v `pwd`/m2cache:/root/.m2 -v `pwd`/sonarcache:/root/.sonar/cache -v`pwd`:`pwd` -w`pwd` maven:3.6.3-jdk-8  curl https://sonarqube.mycompany.software

<!doctype html><html lang="en"><head><meta http-equiv="content-type" content="text/html; charset=UTF-8" charset="UTF-8"/><meta http-equiv="X-UA-Compatible" content="IE=edge"><link rel="apple-touch-icon" href="/apple-touch-icon.png"><link rel="apple-touch-icon" sizes="57x57" href="/apple-touch-icon-57x57.png"><link rel="apple-touch-icon" sizes="60x60" href="/apple-touch-icon-60x60.png">
[... And a lot more output ... ]

正如我所料,它以 sonarqube 索引頁響應。

據我所知,docker maven 圖像中沒有代理設置。

這很令人沮喪。

有沒有人知道這里發生了什么以及如何解決這個問題?

[編輯] 所以我嘗試了很多東西,其中一個奏效了:使用另一個 docker 圖像。 In particular, I've tried all the available maven jdk-8 images available here: https://hub.docker.com/_/maven , and one actually worked, while all other failed: maven:3.6.3-ibmjava-8 .

它看起來像與 java-8 相關的問題,因為所有 JDK 11 映像都按預期工作。 不幸的是,該項目位於 Java 8 中,升級 JVM 時一切都會中斷:-)

我把它留在這里作為一種解決方法,但我仍然想知道為什么它會在其他 docker 圖像中失敗,以及將來如何解決這個問題。

maven 和 gradle sonarqube 分析我也遇到了這個問題,我只有 jdk8-u252+ 的這個問題。 Maven 3.6.3官方鏡像有jdk8-u262。 對我來說,使用 maven 3.5.2 沒問題(jdk-u232)。

For the root cause, it could be the javax.net.ssl new features shipped in u252: https://www.oracle.com/java/technologies/javase/8u251-relnotes.html

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM