14

sonarqube 5.5 几个Java项目,都设置了任何人都可以执行分析的权限。使用 mvn sonar:sonar 运行分析 其他项目工作正常,没有错误。发现一个项目没有权限集。它给了:

未经授权。分析这个项目需要经过身份验证。请提供属性 sonar.login 和 sonar.password 的值。

设置权限并不能解决它。这个项目继续给出这个错误。

采取的步骤:

  • 正在“项目权限”页面上设置权限,将“任何人”组添加到“执行分析”权限。用户 0,组 1

  • 关闭权限然后再次打开。

  • 重启服务器。
  • 删除本地声纳/缓存

有两个名称相同但键不同的项目。QA 版本和发布。

不知道接下来要尝试什么。


------ 短日志 --- mvn -X 如下

[INFO] 
[INFO] --- sonar-maven-plugin:3.0.2:sonar (default-cli) @ adminportal-api ---
[INFO] User cache: /Users/kenhargreaves/.sonar/cache
[INFO] Load global repositories
[INFO] Load global repositories (done) | time=265ms
[INFO] User cache: /Users/kenhargreaves/.sonar/cache
[INFO] Exclude plugins: devcockpit, buildstability, pdfreport, report, scmstats, buildbreaker, views, jira
[INFO] Load plugins index
[INFO] Load plugins index (done) | time=16ms
[INFO] SonarQube version: 5.5
[INFO] Default locale: "en_US", source code encoding: "UTF-8"
[INFO] -- Cache for project [com.fusemail:adminportal-api] not found, synchronizing data..
[INFO] Load rules
[INFO] Load rules (done) | time=244ms
[INFO] Load project settings
[INFO] Load project settings (done) | time=182ms
[INFO] Load project quality profiles
[INFO] Load project quality profiles (done) | time=59ms
[INFO] Load project active rules
[INFO] Load project active rules (done) | time=888ms
[INFO] Load server issues
[INFO] Load server issues (done) | time=844ms
[INFO] Load user information
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 8.221 s
[INFO] Finished at: 2016-07-22T11:39:38-07:00
[INFO] Final Memory: 65M/470M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.0.2:sonar (default-cli) on project adminportal-api: Not authorized. Analyzing this project requires to be authenticated. Please provide the values of 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] 

-----------------
INFO] Default locale: "en_US", source code encoding: "UTF-8"
[DEBUG] Work directory: /Users/kenhargreaves/Documents/workspace/fm-api-portalapi/target/sonar
[DEBUG] Execution getVersion
[DEBUG] Execution execute
[DEBUG] cache: /Users/kenhargreaves/.sonar/ws_cache/http%3A%2F%2Fsonarqube.electric.net/5.5/projects/com.fusemail%3Aadminportal-api
[INFO] -- Cache for project [com.fusemail:adminportal-api] not found, synchronizing data..
[INFO] Load rules
[DEBUG] GET 200 http://sonarqube.electric.net/api/rules/list.protobuf | time=100ms
[INFO] Load rules (done) | time=176ms
[INFO] Load project settings
[DEBUG] GET 200 http://sonarqube.electric.net/batch/project.protobuf?key=com.fusemail%3Aadminportal-api&issues_mode=true | time=53ms
[INFO] Load project settings (done) | time=158ms
[INFO] Load project quality profiles
[DEBUG] GET 200 http://sonarqube.electric.net/api/qualityprofiles/search.protobuf?projectKey=com.fusemail%3Aadminportal-api | time=41ms
[INFO] Load project quality profiles (done) | time=53ms
[INFO] Load project active rules
[DEBUG] GET 200 http://sonarqube.electric.net/api/rules/search.protobuf?f=repo,name,severity,lang,internalKey,templateKey,params,actives&activation=true&qprofile=c-sonar-way-50322&p=1&ps=500 | time=128ms
[DEBUG] GET 200 http://sonarqube.electric.net/api/rules/search.protobuf?f=repo,name,severity,lang,internalKey,templateKey,params,actives&activation=true&qprofile=cpp-sonar-way-23842&p=1&ps=500 | time=160ms
[DEBUG] GET 200 http://sonarqube.electric.net/api/rules/search.protobuf?f=repo,name,severity,lang,internalKey,templateKey,params,actives&activation=true&qprofile=java-sonar-03590&p=1&ps=500 | time=64ms
[DEBUG] GET 200 http://sonarqube.electric.net/api/rules/search.protobuf?f=repo,name,severity,lang,internalKey,templateKey,params,actives&activation=true&qprofile=js-sonar-way-84357&p=1&ps=500 | time=103ms
[DEBUG] GET 200 http://sonarqube.electric.net/api/rules/search.protobuf?f=repo,name,severity,lang,internalKey,templateKey,params,actives&activation=true&qprofile=objc-sonar-way-52782&p=1&ps=500 | time=123ms
[DEBUG] GET 200 http://sonarqube.electric.net/api/rules/search.protobuf?f=repo,name,severity,lang,internalKey,templateKey,params,actives&activation=true&qprofile=py-sonar-way-75611&p=1&ps=500 | time=69ms
[INFO] Load project active rules (done) | time=728ms
[INFO] Load server issues
[DEBUG] GET 200 http://sonarqube.electric.net/batch/issues.protobuf?key=com.fusemail%3Aadminportal-api | time=333ms
[INFO] Load server issues (done) | time=524ms
[INFO] Load user information
[DEBUG] GET 401 http://sonarqube.electric.net/batch/users?logins=axxx.mxxxx | time=31ms
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 8.647 s
[INFO] Finished at: 2016-07-22T11:42:01-07:00
[INFO] Final Memory: 66M/467M

我们在那里看到的用户确实在 sonarqube 服务器中有一个帐户,我确实删除了他以查看会发生什么。

4

4 回答 4

25

答案更简单。转到 sonarqube 网页,然后转到管理,然后转到安全并禁用“强制用户身份验证”。祝你好运!

于 2019-09-29T03:49:03.163 回答
7

您是否在 SonarQube 中强制进行身份验证?

如果是这种情况,您基本上需要:

  1. 在 SonarQube 中为用户帐户生成令牌
  2. 在环境变量中公开令牌,SONAR_TOKEN如下所示:
    export SONAR_TOKEN="<your_token>"(bash/GitBash)
    SET SONAR_TOKEN="<your_token>"(bat/Windows)
  3. 在 maven 命令中使用令牌,例如:
    mvn ... sonar:sonar -Dsonar.login=$SONAR_TOKEN(bash/GitBash)
    mvn ... sonar:sonar -Dsonar.login=%SONAR_TOKEN%(bat/Windows)

这在Sonarqube 授权中进行了广泛讨论 - 如何在启用 sonar.forceAuthentication 时使用 sonar-maven-plugin 进行授权

于 2020-09-16T12:57:43.690 回答
3

在使用最新的 sonerQube 尝试声纳扫描仪时,出现以下错误

错误:未授权。分析这个项目需要经过身份验证。请提供属性 sonar.login 和 sonar.password 的值。

解决方案是在项目根配置文件中添加 sonar.login 和 sonar.password 属性。您可以在声纳扫描仪运行期间找到它的路径

信息:扫描仪配置文件:/Users//.sonar/native-sonar-scanner/sonar-scanner-4.4.0.2170-macosx/conf/sonar-scanner.properties

使用以下属性更新此文件 sonar.login= sonar.password=

再试一次,你的问题应该得到解决。

于 2021-01-24T04:06:04.787 回答
1

我有同样的问题并且可以解决它

将 SonarQube 配置从 module 移动build.gradle到 app build.gradle

sonarqube {
    properties {
        property "sonar.host.url", System.getenv("SONAR_URL_KEY")
        property "sonar.login", System.getenv("SONAR_LOGIN_KEY")
        ...
    }
}
于 2017-05-04T06:48:42.407 回答