First time to use sonarCloud analyzing the maven project,but it cannot work because of not authorized

permissions
tokens

(Xuejiangtao) #1
[ERROR] Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.5.0.1254:sonar (default-cli) on project maven-project: Not authorized. Please check the properties sonar.login and sonar.password. -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

my command is
mvn sonar:sonar -Dsonar.projectKey=xuejiangtao_maven-project -Dsonar.organization=xuejiangtao-github -Dsonar.host.url=https://sonarcloud.io -Dsonar.login=xuejiangtao

can someone help me ?


(Xavier Bourguignon) #2

Hi,

I suggest you to use the nice wizard “Create new project”

It will guide you to successfully run your first analysis


(Xuejiangtao) #3


i use the ‘creat new project’ and follow the command:sweat: but it shows not authority


(Scott) #4

Hi.

In the first step (“Provide a token”) select “Generate a token”, give a name for it and click in the button “Generate”.

Then go to the second step and follow the instructions.


(Xuejiangtao) #5

thats what i do in first step:tired_face: it still cant work, should i config the maven’s setting.xml?


(Scott) #6

Ok, long answer then.

This is the image that you send:

Do you see this sonar.login property? It shouldn’t be your SonarQube user. That’s your problem.

This is what I get following the instructions:

  • I gave a name to the token:
    image

  • I clicked “Generate”:
    image

  • Then “Continue” and opened the instructions for Maven projects:

Do you see that the sonar.login property is very different than yours?

Just for comparison, this is what happens when I use the “Use existing token” option.

image
image

I think you used this option before. This won’t work, because the token is not valid (btw, suggestion to SonarSource: can’t you validate this? Like, validating the length or something?)


(Xuejiangtao) #7

hi, Scott.
Many thanks to you. I found it works if using the token like 8394XXXX!!