sonarqube - GitLab SonarQube CI/CD 变量未传递到管道
问题描述
我试图根据以下文档https://docs.sonarqube.org/latest/analysis/gitlab-cicd/将 GitLab CI/CD 与 SonarQube 8.1 集成。
我尝试将 SonarScanner 用于 Maven 示例配置
image: maven:latest
variables:
SONAR_TOKEN: "your-sonarqube-token"
SONAR_HOST_URL: "http://your-sonarqube-url"
GIT_DEPTH: 0
sonarqube-check:
script:
- mvn verify sonar:sonar -Dsonar.qualitygate.wait=true
allow_failure: true
only:
- merge_requests
- master
问题是它看起来像 SONAR_HOST_URL,并且可能由于不清楚的原因忽略了 SONAR_TOKEN。查看管道日志时,我得到
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.6.0.1398:sonar (default-cli) on project sonar-java-test: Unable to execute SonarQube: Fail to get bootstrap index from server: Failed to connect to localhost/0:0:0:0:0:0:0:1:9000: Connection refused (Connection refused) -> [Help 1]
我试图通过使用 gitlab (12.3.2) CI/CD 变量设置变量来解决这个问题,但它不起作用
有任何想法吗?
解决方案
文档似乎不是最新的。
您应该向 maven 命令添加-Dsonar.host.url
和参数以覆盖默认设置:-Dsonar.host.url
image: maven:latest
variables:
SONAR_TOKEN: "your-sonarqube-token"
SONAR_HOST_URL: "http://your-sonarqube-url"
GIT_DEPTH: 0
sonarqube-check:
script:
- mvn verify sonar:sonar -Dsonar.qualitygate.wait=true -Dsonar.host.url=$SONAR_HOST_URL -Dsonar.login=$SONAR_TOKEN
allow_failure: true
only:
- merge_requests
- master
推荐阅读
- asp.net - 在我们使用 devexpress 控件的窗口窗体中,是否可以根据屏幕分辨率调整窗体和布局的大小
- centos7 - 我正在尝试在 centos 7 上远程挂载文件系统
- asp.net - 在不登录用户的情况下更新 AWS Cognito 用户的自定义属性
- reactjs - 如何通过在 StencilJS 中滚动到顶部来在加载内容时保持滚动位置?
- css - 在 Chrome 中组合过滤器和 :hover 时出现奇怪的行为
- javascript - (Fullcalendar 4 VueJS) - 从 AM/PM 到 24H 的行时间格式
- c# - 如何关闭/处置 Nlog 的直布罗陀代理?
- jquery - 如何使用 Asp.Net Webform 和 Ajax 获得确认框?
- javascript - 尝试以“计数器”设置动画时返回错误值
- python - 使用 sqlalchemy 根据 python 列表更新数据库表