0

On SonarCloud, I created an organization and a user (from GitHub), plus a project. For the user I created a token. Then I ran the command

mvn org.sonarsource.scanner.maven:sonar-maven-plugin:3.5.0.1254:sonar -Dsonar.projectKey=<project key> -Dsonar.organization=<my org> -Dsonar.host.url=https://sonarcloud.io -Dsonar.login=<token>

I come up with the error message

[ERROR] Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.5.0.1254:sonar (default-cli) on project XXX: You're not authorized to run analysis. Please contact the project administrator.

In the project settings > Administration > Permissions, the user does have "Execute Analysis" permission.

If I add the "Execute Analysis" permission to Anyone, the command above works (it does not need the -Dsonar.login option).

Does anyone have a clue?

Ivan dal Bosco
  • 3,233
  • 4
  • 19
  • 24

2 Answers2

0

Adding the "Execute Analysis" permission to the SonarCloud user who generated the token should be enough.

Can you retry with:

mvn sonar:sonar 
   "-Dsonar.projectKey=<project key>" \
   "-Dsonar.organization=<my org>" \
   "-Dsonar.host.url=https://sonarcloud.io" \
   "-Dsonar.login=<token>"

In case it doesn't work, can you provide the output of the command?

  • Hello @Jean-Alexis. Yes, this is what I did, to no avail. Thanks for your assistance. – Ivan dal Bosco Feb 14 '19 at 08:00
  • I came across the same issue and I had to grant "Execute Analysis" permission to the the "Anyone" pseudo-group for it to work. This is described [here](https://sonarcloud.io/documentation/analysis/analysis-parameters/#authentication). – dlresende Nov 27 '20 at 11:20
0

It turns out that SonarCloud works as expected. I had forgotten that some people in my organization seem to enjoy making their colleagues' life miserable. Sneakily removing items such as sonar.login from the requests is one among their tricks.

Ivan dal Bosco
  • 3,233
  • 4
  • 19
  • 24