Gitlab CI + SonarQube

Hello,

I’m trying to set up my sonarqube server but it’s not working for some reason, in .m2/settings.xml I have specified

<profile>
  <id>sonar</id>
  <activation>
    <activeByDefault>true</activeByDefault>
  </activation>
  <properties>
    <sonar.host.url>(hidden)</sonar.host.url>
    <sonar.login>(hidden)</sonar.login>
  </properties>
</profile>

I’m trying to integrate it with GitLab, so, in my .gitlab-ci.yml I added

sonarqube-check:
  stage: sonarqube-check
  variables:
    SONAR_USER_HOME: ".sonar"  # Defines the location of the analysis task cache
    GIT_DEPTH: "0"  # Tells git to fetch all the branches of the project, required by the analysis task
    SONAR_HOST_URL: "$SONAR_HOST_URL"
    SONAR_TOKEN: "$SONAR_LOGIN"
  cache:
    key: "${CI_JOB_NAME}"
    paths:
      - .sonar/cache
      - .m2
  script:
    - 'mvn verify sonar:sonar -Dsonar.qualitygate.wait=true -s ci_settings.xml'
  allow_failure: true

But it’s still looking for the https://locahost:9000 and fails with

 SonarQube server [http://localhost:9000] can not be reached

What am I doing wrong? I don’t have experience with ci so I’m learning on the go

Thanks for help

Hey there.

This value is probably overriding everything. Is it set, and if so, to what value?

I’m not a Gitlab expert, but strictly following the UI tutorial in SonarQube when configuring GitLab CI, I don’t think you need SONAR_HOST_URL or SONAR_TOKEN defined in your .gitlab-ci.yml file, only under Settings > CI/CD > Variables

Hello, It doesn’t work if I remove it. I’m trying to read the value from maven settings.xml