I am using the Azure Devops integration and have followed all of the steps detailed in your docs, but am getting a error when the analysis tries to run.
I am running on an Azure hosted build agent with the Service Connection setup and a PAT for the PR integration. We are running our builds using the dotnet CLI rather than MsBuild. So possibly this is related to the issue we are seeing. I can’t see anything in the docs that covers this use case though.
I have managed to get some results into the account manually on my local command line using the dotnet-sonarcloud tool, but I don’t want to have to put a access token into the source control and would rather use the extension and service connection for security.
Thanks: Below is the error I see in azure devops.
INFO: ------------------------------------------------------------------------
INFO: EXECUTION FAILURE
INFO: ------------------------------------------------------------------------
INFO: Total time: 44.456s
INFO: Final Memory: 7M/27M
##[error]ERROR: Error during SonarScanner execution
ERROR: Error during SonarScanner execution
INFO: ------------------------------------------------------------------------
##[error]ERROR: Not authorized. Please check the properties sonar.login and sonar.password.
ERROR:
ERROR: Not authorized. Please check the properties sonar.login and sonar.password.
ERROR:
##[error]The SonarQube Scanner did not complete successfully
The SonarQube Scanner did not complete successfully
##[error]16:25:26.962 Post-processing failed. Exit code: 1
16:25:26.962 Post-processing failed. Exit code: 1
##[error]The process ‘D:\a_tasks\SonarCloudPrepare_14d9cde6-c1da-4d55-aa01-2965cd301255\1.12.0\classic-sonar-scanner-msbuild\SonarScanner.MSBuild.exe’ failed with exit code 1
This is our yaml for the build (the scannerMode: ‘MSBuild’ seems wrong, but I can’t think what other value to use)
steps:
-
task: SonarCloudPrepare@1
inputs:
SonarCloud: ‘{redacted}’
organization: ‘{redacted}’
scannerMode: ‘MSBuild’
projectKey: ‘{redacted}’
projectName: ‘{redacted}’ -
task: DotNetCoreInstaller@2
displayName: ‘Install .Net Core 3.x SDK’
inputs:
packageType: ‘sdk’
version: ‘3.x’ -
task: DotNetCoreCLI@2
displayName: ‘Restore Nugets - dotnet CLI’
inputs:
command: ‘restore’
projects: ‘$(solution)’
feedsToUse: ‘config’
nugetConfigPath: ‘NuGet.config’
externalFeedCredentials: ‘{redacted}t’ -
task: DotNetCoreCLI@2
displayName: ‘Build Solution - dotnet CLI’
inputs:
command: ‘build’
projects: ‘(solution)' configuration: '(buildConfiguration)’
arguments: ‘–no-restore’ -
task: DotNetCoreCLI@2
displayName: ‘Test Solution’
inputs:
command: ‘test’
projects: ‘**/*.Tests.csproj’
arguments: ‘–collect “Code coverage” --no-restore --no-build’ -
task: SonarCloudAnalyze@1
displayName: ‘Analysis SonarCloud’ -
task: SonarCloudPublish@1
displayName: ‘Publish SonarCloud’
inputs:
pollingTimeoutSec: ‘300’