首页 > 解决方案 > 无法在 GitLab 管道中到达 SONAR_HOST_URL

问题描述

我正在尝试在 GitLab Pipeline 中集成 SonarQube 社区版本来分析我的 .Net Core 项目。我按照这个指令GitLab CI/CD | SonarQube 文档

但是当我尝试运行此管道时,它会因以下日志而失败: 管道作业结果

我的 gitlab-ci.yml:

    sonarqube-check:
  image:
    name: sonarsource/sonar-scanner-cli:latest
    entrypoint: [""]
  variables:
    SONAR_USER_HOME: "${CI_PROJECT_DIR}/.sonar"  # Defines the location of the analysis task cache
    SONAR_HOST_URL: "https://sonarqube.******.com/"
    GIT_DEPTH: "0"  # Tells git to fetch all the branches of the project, required by the analysis task
  cache:
    key: "${CI_JOB_NAME}"
    paths:
      - .sonar/cache
  script:
    - sonar-scanner -Dsonar.qualitygate.wait=true
  allow_failure: true
  only:
    - merge_requests
    - master
    - develop

我也尝试在 GitLab 的变量设置中指定 SONAR_TOKEN 和 SONAR_HOST_URL,但结果是一样的。任何 SONAR_HOST_URL 链接都会失败并出现相同的错误。

我尝试设置 http://localhost:9000/ 也失败了。我还尝试使用保证 SONAR_HOST_URL 可用的链接(如 google.com),但对于 pipline 也无法访问。

标签: gitlabsonarqubegitlab-ci

解决方案


推荐阅读