I've got sonarqube 6.5 with default configs. When sonar.forceAuthentication flag is set to false, I can create and analyse project through command given below.
mvn sonar:sonar -Dsonar.host.url=https://mySonarHost/sonar -Dsonar.login=mySonarUserKey
When I enable sonar.forceAuthentication parameter (sonar.forceAuthentication=true), I can't analyse project. I always get maven error:
[ERROR] Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.3.0.603:sonar (default-cli) on project storm: Not authorized. Please check the properties sonar.login and sonar.password. -> [Help 1]
It doesn't work on default admin account nor created user account (with permission to analyse project). I've also tried not to use user key, but user' login and password (-Dsonar.login
and -Dsonar.password
in maven config) but it also doesn't work.
I've tried to use different sonar version (from 4.5.7, through 5.6.6 to the newest, 6.5, but I always get the same result).
During the connection, I've got such messages in my access.log:
IP_ADDRESS - - [08/Sep/2017:12:03:33 +0200] "GET /sonar/batch/index HTTP/1.1" 200 - "-" "ScannerMaven/3.3.0.603/3.5.0" "SOME_KEY"
IP_ADDRESS - - [08/Sep/2017:12:03:33 +0200] "GET /sonar/api/settings/values.protobuf HTTP/1.1" 401 - "-" "ScannerMaven/3.3.0.603/3.5.0" "SOME_KEY"
It's required for me to set sonar.forceAuthentication parameter to true (only trusted users can have access to it).
Any idea how to configure and access sonarqube through maven with credential parameters?
This is a minimal command that I use to update Sonar Cube Dashboard for my project,
You can always wrap a string value in double quotes if it has spaces in it.
Before using above command, you need to generate token for your user id as specified in answer provided by Eric. There is no need to pass password property.
Did you set both
sonar.login
andsonar.password
parameters (https://docs.sonarqube.org/display/SCAN/Analyzing+with+SonarQube+Scanner+for+Maven#AnalyzingwithSonarQubeScannerforMaven-Security) ?Note that in recent versions (like SonarQube 6.5), you should use a user token and just set it in the
sonar.login
parameter: https://docs.sonarqube.org/display/SONAR/User+Token