我正在为 .NET 项目配置 GitLab ci 管道。我正在尝试使用声纳云运行代码分析。当我运行分析时,我陷入了错误提示
ERROR: You’re not authorized to run analysis. Please contact the project administrator.
,
似乎分析报告已生成,当尝试将分析报告上传到声纳云时,执行失败并出现错误。 请建议如何克服此错误并成功运行分析。
PowerShell 脚本中用于运行分析的命令:
echo "sonarqube installation"
dotnet tool install --global dotnet-sonarscanner --version 5.2.0
dotnet sonarscanner begin /k:"proj1" /d:sonar.login="auth-token" /d:sonar.host.url="https://sonarqube-server.com" /d:project.settings="C:\builds\proj1\sonar-project.properties"
# dotnet build command
dotnet sonarscanner end /d:sonar.login="auth-token"
echo "sonar scanning completed"
这是我的声纳项目.properties。我现在已经删除了这些值。
# required metadata
sonar.projectKey=proj1
sonar.projectName=proj1
sonar.projectVersion=1.6
sonar.organization=proj1
sonar.sources='sources list'
sonar.javascript.lcov.reportPath=
sonar.javascript.jstest.reportsPath=
#ignore rules
sonar.issue.ignore.multicriteria=
# function complexity
sonar.issue.ignore.multicriteria.e1.ruleKey=
sonar.issue.ignore.multicriteria.e1.resourceKey=
# unused variable
sonar.issue.ignore.multicriteria.e2.ruleKey=
sonar.issue.ignore.multicriteria.e2.resourceKey=
# function with too many line
sonar.issue.ignore.multicriteria.e3.ruleKey=
sonar.issue.ignore.multicriteria.e3.resourceKey=
# trailing comma
sonar.issue.ignore.multicriteria.e4.ruleKey=
sonar.issue.ignore.multicriteria.e4.resourceKey=
# === and !==
sonar.issue.ignore.multicriteria.e5.ruleKey=
sonar.issue.ignore.multicriteria.e5.resourceKey=
# Commented Code
sonar.issue.ignore.multicriteria.e6.ruleKey=
sonar.issue.ignore.multicriteria.e6.resourceKey=
# Nested If Depth
sonar.issue.ignore.multicriteria.e7.ruleKey=
sonar.issue.ignore.multicriteria.e7.resourceKey=
sonar.issue.ignore.multicriteria.e8.ruleKey=
sonar.issue.ignore.multicriteria.e8.resourceKey=
# Trailing Whitespace
sonar.issue.ignore.multicriteria.e9.ruleKey=
sonar.issue.ignore.multicriteria.e9.resourceKey=
# Literal boolean values
sonar.issue.ignore.multicriteria.e10.ruleKey=
sonar.issue.ignore.multicriteria.e10.resourceKey=
# Variables and functions redeclared
sonar.issue.ignore.multicriteria.e11.ruleKey=
sonar.issue.ignore.multicriteria.e11.resourceKey=
# Unused function argument
sonar.issue.ignore.multicriteria.e12.ruleKey=
sonar.issue.ignore.multicriteria.e12.resourceKey=
我尝试授予在声纳云中运行分析的所有权限。
对我来说,在 SONAR 中生成新令牌(Sonarcloud->帐户->我的帐户->安全->输入令牌名称->生成->复制令牌)并使用环境变量在 bibucket 中配置生成的令牌后,未授权错误得到解决名为 SONAR_TOKEN 的 bitbucket 存储库。删除 bitbucket 中配置的所有旧 SONAR_TOKEN。之前配置的令牌被某人撤销,导致未授权错误。
看看在 Gitlab 集成中是否同样有效
尝试从命令提示符运行它