1.背景
编辑gitlab-ci流水线时,代码分析的job,maven使用sonar报错
- mvn clean verify sonar:sonar -Dsonar.login=30c55d3b8d3d2569431fb39f3c488c90643a6844
2.错误信息
[ERROR] Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.11.0.3922:sonar (default-cli) on project test: Unable to execute SonarScanner analysis: Fail to get bootstrap index from server: Host is unreachable (Host unreachable) -> [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
3.排查过程及解决
排查:
开始以为是scanner的版本问题,指定了scanner的版本,不行
后通过官方文档排查maven配置,发现sonar.host.url中的地址打错了
解决:修改setting.xml重新制作maven基础镜像,启动流水线运行成功
参考:
sonarqube文档:
https://docs.sonarsource.com/sonarqube/8.9/analyzing-source-code/scanners/sonarscanner-for-maven/
其他:
https://blog.csdn.net/q54244125/article/details/83866089