我有带有默认配置的 sonarqube 6.5。当 sonar.forceAuthentication 标志设置为 false 时,我可以通过下面给出的命令创建和分析项目。
mvn sonar:sonar -Dsonar.host.url=https://mySonarHost/sonar -Dsonar.login=mySonarUserKey
当我启用 sonar.forceAuthentication 参数 (sonar.forceAuthentication=true) 时,我无法分析项目。我总是得到 Maven 错误:
[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]
它不适用于默认管理员帐户或创建的用户帐户(具有分析项目的权限)。我也尝试过不使用用户密钥,而是使用用户的登录名和密码(-Dsonar.login
以及-Dsonar.password
在 Maven 配置中),但它也不起作用。我尝试使用不同的声纳版本(从 4.5.7、5.6.6 到最新的 6.5,但我总是得到相同的结果)。
在连接期间,我的 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"
我需要将 sonar.forceAuthentication 参数设置为 true(只有受信任的用户才能访问它)。
知道如何通过带有凭据参数的 Maven 配置和访问 sonarqube 吗?