Can only access docker sonarqube, not sonarcloud from my local build

Hi,

I can only run my repo with sonarscanner against a local docker sonarqube server.

If I try to change the scanner config to sonarcloud I either get:

11:52:23.185 Failed to request and parse ‘https://sonarcloud.io/api/settings/values?component=xxx’: The remote server returned an error: (401) .
11:52:23.188 Could not authorize while connecting to the SonarQube server. Check your credentials and try again.

with login credentials (I have provided my token and secret), or:

11:52:11.621 11:52:11.621 WARNING: To analyze private projects make sure the scanner user has ‘Browse’ permission.
(I have turned on all permissions)

with token (by just specifying key in sonarscanner begin)

I am about to give up sonarcloud. Is there some problems with sonarcloud at the moment?

Thank you!

Can you please share the command you use when you run the scanner against SonarCloud?

Is your project on SonarCloud public or private? (Can you share the link?)

Hi janos

It´s .Net core so i run
dotnet sonarscanner begin /k: "project-key" (or /key in git bash for example)
dotnet build <path to solution.sln>
dotnet sonarscanner end

It´s a private sonarcloud project

And my SonarQube.Analysis.xml just contains host url when i use token

  <Property Name="sonar.host.url">https://sonarcloud.io</Property>


and also login password when i tried to  use credentials
  
  <Property Name="sonar.login">xxx</Property>
  <Property Name="sonar.password">xxxxxxxxxxxxxxxxxxxxxxxxx</Property>

You need to specify the token in the begin and end steps, like this:

dotnet sonarscanner begin /k:"project-key" /d:sonar.login=<token>
dotnet build <path to solution.sln>
dotnet sonarscanner end /d:sonar.login=<token>

Thanks Janos

You made me realize that I have put in the token name and not the value.
Now I can run sonarscanner begin

I used your way and came further than before, but now sonarscanner end crashes:

14:36:40.313 INFO: EXECUTION FAILURE
14:36:40.313 INFO: ------------------------------------------------------------------------
14:36:40.314 INFO: Total time: 18.175s
14:36:40.533 INFO: Final Memory: 38M/647M
14:36:40.533 INFO: ------------------------------------------------------------------------
14:36:40.535 ERROR: Error during SonarQube Scanner execution
14:36:40.536 ERROR: Organization of component with key 'xxx' does not match specified organization 'default'

I tried putting /d:sonar.organization=“xxx” which is invalid and /o:sonar.organization=“xxx” which gives me an 404

Do you know anything about this default parameter?

EDIT:
Finally got it all working. I didn´t find all this in the documentation but my final commands look like

 dotnet sonarscanner begin /k:"xxxxx" /o:xxx /d:sonar.host.url="https://sonarcloud.io" /d:sonar.login="xxxxxxxxxxxxxx"
 dotnet build <path to solution.sln>
 dotnet sonarscanner end /d:sonar.login="xxxxxxxxxxxxxx"

and of course not the token name but the value
It was tricky to find out that you have to write /o:organization when it was /d:sonar.organization=“xxx” before

Thanks

I’m glad you got it working. I’m surprised our documentation pages don’t mention the /o: parameter, and I think they should. I created a ticket SONAR-12183 to fix this. Thanks for reporting!