Hi @Dipenduroy,
It seems like there is a confusion somewhere in your configuration between SonarQube and SonarCloud.
Could you please check if you have Global Environment variable on GitLab side? (Settings > CI/CD > Variables)
First of all, When i didn’t pass the host url in gitlab ci yaml it gave below error, it should automatically pick the environment variables defined in gitlab ci/cd settings, But it didn’t, so I guess this is a bug.
INFO: User cache: /builds/Dipendu/world4help/.sonar/cache
ERROR: SonarQube server [http://localhost:9000] can not be reached
Concerning the first error where the SONAR_HOST_URL environment variable is not read by the scanner. I can see in your screenshot that the variable was marked as protected. The GitLab documentation states Protected variables are only exposed to protected branches or tags. My guess is that the branch branch-test was not protected. You can configure this under Settings > Repository > Protected Branches
Concerning the second error You're not authorized to run analysis. Please contact the project administrator. This is probably because the SONAR_TOKEN variable is not read correctly either.
You can either
run it from a protected branch
uncheck the protected flag for the variable
add it to the sonar-scanner command: sonar-scanner -Dsonar.token=<token>.
Since your repository is public I recommend the first option.
Hi @TomVanBraband,
I am glad that you could find the issue of why sonarcloud was unable to start due to missing variables. Thanks, and after your help, I was able to start the multiple branch sonarcloud analysis only after adding the branch parameter in the command as below.
If the issue is not resolved yet, can you check if the token you defined is still valid?
You can find this by navigation to your organization on SonarCloud and clicking on Administration > Organization settings
@TomVanBraband The issue of comments on merge request is resolved after i added the test cases and its configuration in Sonar Scan. Thanks for your help.