英文:
ERROR: Validation of project failed o To use the property "sonar.branch.name" and analyze branches
问题
解决方案
由SonarCommunity/Forum提供的命令未解决问题,请参见下面的片段,但通过学习dotnet框架的方法,我们成功地解决了问题,基本上是从env:Variable中删除有问题的Property,请参见解决方案片段,
SonarCommunity建议的解决方案(未生效)
$params = "$env:SONARQUBE_SCANNER_PARAMS" -replace '"sonar.branch.name":"[\w,/,-]*",?'
Write-Host "##vso[task.setvariable variable=SONARQUBE_SCANNER_PARAMS]$params"
通过PSObject.Properties dotnet方法的功能性解决方案
$params = "$env:SONARQUBE_SCANNER_PARAMS.PSObject.Properties('sonar.branch.name')"
Write-Host "##vso[task.setvariable variable=SONARQUBE_SCANNER_PARAMS]$params"
以上片段使我们能够恢复SonarQube代码扫描,希望也能帮助到大家!
错误描述
- 这是Azure DevOps构建管道
- 在SonarQube任务中,我们传递下一个键值对
{"project-key":"value","project-name":"value","project-version":"value"}
- 从SonarQube“Developer Edition”降级为“Community Edition”后,我们一直遇到标题中的错误,见下面的片段,更重要的是在SonarQube任务“运行代码分析”中创建了一个故障。
##[error]ERROR: Validation of project failed:
o To use the property "sonar.branch.name" and analyze branches, Developer Edition or above is required. See https://redirect.sonarsource.com/doc/branches.html for more information.
已测试的操作
在互联网上研究后找到了下一个PowerShell脚本,但在如何实施它方面没有太多的上下文,见下面的片段,因为是通过传递一个变量进行的“命令调用”来删除对“sonar.branch.name”的使用,但据我所知,这应该是由ADO的任务接收的:
$params = "$env:SONARQUBE_SCANNER_PARAMS" -replace '"sonar.branch.name":"[\w,/,-]*",?'
Write-Host "##vso[task.setvariable variable=SONARQUBE_SCANNER_PARAMS]$params"
当我实施这个任务时,所有的单元测试都失败了,因此单元测试任务一直挂起,直到ADO超时关闭流水线运行
也许我应该在“准备分析配置”任务之前添加这个任务,然后将变量$param传递到任务“准备分析配置”的“高级”部分?请参见下面的屏幕截图:
我们目前停止了所有代码分析,寻找解决方案时苦苦挣扎。
英文:
Solution for this thread
The command provided by the SonarCommunity/Forum did not solve the issue, see snippet below, but by learning the dotnet framework method we manage, so basically we remove to problematic Property from the env:Variable, see solution snippet below,
SonarCommunity suggested solution (didn't work)
$params = "$env:SONARQUBE_SCANNER_PARAMS" -replace '"sonar.branch.name":"[\w,/,-]*"\,?'
Write-Host "##vso[task.setvariable variable=SONARQUBE_SCANNER_PARAMS]$params"
Functional solution via the PSObject.Properties dotnet Method
$params = "$env:SONARQUBE_SCANNER_PARAMS.PSObject.Properties('sonar.branch.name')"
Write-Host "##vso[task.setvariable variable=SONARQUBE_SCANNER_PARAMS]$params"
Above snippet allowed us to bring back our SonarQube code scanning, hope help you all as well!
Error Description
-
This is an Azure DevOps Build Pipeline
-
In the SonarQube Task we pass the next Key-value pairs
{"project-key":"value","project-name":"value","project-version":"value"}
-
System-wide we were downgraded from SonarQube "Developer Edition" to "Community Edition" since then we are experiencing the error from the title of this threat, see below snippet, and more importantly is creating a failure in the SonarQube task "Run code Analysis"
##[error]ERROR: Validation of project failed:
o To use the property "sonar.branch.name" and analyze branches, Developer Edition or above is required. See https://redirect.sonarsource.com/doc/branches.html for more information.
What actions have been tested
Researching on the internet found the next powershell script but there isn't much context on how it should be implemented, see below snippet, because is it through a variable passing a "command call" for removing the usage of "sonar.branch.name" but this should be pick-up by a task from what I know by working with ADO:
$params = "$env:SONARQUBE_SCANNER_PARAMS" -replace '"sonar.branch.name":"[\w,/,-]*"\,?'
Write-Host "##vso[task.setvariable variable=SONARQUBE_SCANNER_PARAMS]$params"
When I do implement this task all the Unit-test fails, so the unit test task hangs until ADO by timeout closes the Pipeline run
Maybe should I Add this task before the "Prepare Analysis Configuration" task and afterwards pass the variable $param to the "advance" section of the Task "Prepare Analysis Configuration"? see screenshot below:
All help will be more than welcome we have all code analysis stopped at the moment and pulling our hair to find a solution
答案1
得分: 0
这个线程的解决方案
SonarCommunity/Forum提供的命令未解决问题,参见下面的片段,但通过学习dotnet框架的方法,我们成功地解决了问题,基本上是从env:Variable中移除了有问题的属性,参见解决方案片段,
SonarCommunity建议的解决方案(未生效)
$params = "$env:SONARQUBE_SCANNER_PARAMS" -replace '"sonar.branch.name":"[\w,/,-]*"\,?'
Write-Host "##vso[task.setvariable variable=SONARQUBE_SCANNER_PARAMS]$params"
通过PSObject.Properties dotnet方法的功能性解决方案
$params = "$env:SONARQUBE_SCANNER_PARAMS.PSObject.Properties('sonar.branch.name')"
Write-Host "##vso[task.setvariable variable=SONARQUBE_SCANNER_PARAMS]$params"
上面的片段使我们成功恢复了SonarQube代码扫描,希望对大家有所帮助!
英文:
Solution for this thread
The command provided by the SonarCommunity/Forum did not solve the issue, see snippet below, but by learning the dotnet framework method we manage, so basically we remove to problematic Property from the env:Variable, see solution snippet below,
SonarCommunity suggested solution (didn't work)
$params = "$env:SONARQUBE_SCANNER_PARAMS" -replace '"sonar.branch.name":"[\w,/,-]*"\,?'
Write-Host "##vso[task.setvariable variable=SONARQUBE_SCANNER_PARAMS]$params"
Functional solution via the PSObject.Properties dotnet Method
$params = "$env:SONARQUBE_SCANNER_PARAMS.PSObject.Properties('sonar.branch.name')"
Write-Host "##vso[task.setvariable variable=SONARQUBE_SCANNER_PARAMS]$params"
The above snippet allowed us to bring back our SonarQube code scanning, hope help you all as well!
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论