[英]GitLab SonarQube CI/CD variables are not passed to the Pipeline
I was trying to integrate the GitLab CI/CD with SonarQube 8.1 based on the following documentation https://docs.sonarqube.org/latest/analysis/gitlab-cicd/ .我试图根据以下文档https://docs.sonarqube.org/latest/analysis/gitlab-cicd/将 GitLab CI/CD 与 SonarQube 8.1 集成。
I tried to use the SonarScanner for Maven sample configurations我尝试将 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
The problem is that it looks like the SONAR_HOST_URL, and probably, the SONAR_TOKEN is ignored for unclear reason.问题是它看起来像 SONAR_HOST_URL,并且可能由于不清楚的原因忽略了 SONAR_TOKEN。 When looking at the pipeline log I get查看管道日志时,我得到
[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]
I tried to workaround this by setting the variables using the gitlab (12.3.2) CI/CD variables, but it doesn't work我试图通过使用 gitlab (12.3.2) CI/CD 变量设置变量来解决这个问题,但它不起作用
Any ideas?有任何想法吗?
The documentation seems not up-to-date.文档似乎不是最新的。
You should add -Dsonar.host.url
and -Dsonar.host.url
arguments to the maven command to ovveride the default settings :您应该将-Dsonar.host.url
和-Dsonar.host.url
参数添加到 maven 命令以-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
The Protected
toggle in the Gitlab > Variables
screenshot refers to Protected Branches and Tags . Gitlab > Variables
屏幕截图中的Protected
切换是指Protected Branches and Tags 。 It does not mean the variable is protected.这并不意味着该变量受到保护。
It is the Masked
toggle that protects the variable being leaked into logs etc. Masked
切换可以保护泄漏到日志等中的变量。
gitlab-ci understands the variables SONAR_TOKEN
and SONAR_HOST_URL
gitlab-ci 理解变量SONAR_TOKEN
和SONAR_HOST_URL
Reference: https://docs.sonarqube.org/latest/analysis/gitlab-cicd/参考: https : //docs.sonarqube.org/latest/analysis/gitlab-cicd/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.