Hello,
we are currently running sonarcloud in combination with azure devops.
When merging a branch, the resulting analysis runs without problems, however when done for a pull request it gives the following error:
INFO: Load project branches
INFO: Load project branches (done) | time=110ms
INFO: Check ALM binding of project 'medialen_xFund-backend'
INFO: Detected project binding: BOUND
INFO: Check ALM binding of project '###-backend' (done) | time=31ms
INFO: Load project pull requests
INFO: Load project pull requests (done) | time=31ms
INFO: Load branch configuration
##[error]ERROR: Could not find the pullrequest with key '3852'
ERROR: Caused by: Error 404 on https://sonarcloud.io/api/alm_integration/show_pullrequest?project=###-backend&pullrequestKey=3852 : {"errors":[{"msg":"Unable to find the pullrequest with key \u00273852\u0027"}]}
ERROR:
ERROR: Could not find the pullrequest with key '3852'
ERROR: Caused by: Error 404 on https://sonarcloud.io/api/alm_integration/show_pullrequest?project=##-backend&pullrequestKey=3852 : {"errors":[{"msg":"Unable to find the pullrequest with key \u00273852\u0027"}]}
ERROR:
##[error]The SonarScanner did not complete successfully
The SonarScanner did not complete successfully
##[error]16:44:22.199 Post-processing failed. Exit code: 1
16:44:22.199 Post-processing failed. Exit code: 1
##[error][ERROR] SonarQube Cloud: Error while executing task Analyze: The process 'D:\Agents\Agent-1\_work\_tasks\SonarCloudPrepare_14d9cde6-c1da-4d55-aa01-2965cd301255\3.1.1\classic-sonar-scanner-msbuild\SonarScanner.MSBuild.exe' failed with exit code 1
##[error]The process 'D:\Agents\Agent-1\_work\_tasks\SonarCloudPrepare_14d9cde6-c1da-4d55-aa01-2965cd301255\3.1.1\classic-sonar-scanner-msbuild\SonarScanner.MSBuild.exe' failed with exit code 1
As suggested in other topics, I have replaced the personal access token with a new one with permissions to read and write code, unfortunately this has not fixed the issue. What I did notice is that when traversing the alm integration link (https://sonarcloud.io/api/alm_integration/show_pullrequest?project=###-backend&pullrequestKey=3852) I get the same not found error.
I have checked that the pull requests still exist, and when changing the project name it changes to the project not existing, so it does find the project.
Edit: The pull request tab in SonarCloud does not show any pull requests.
Another Issue we have, which may be related, is that the code coverage is not detected. Though this may also be a simple configuration error:
Calling the TFS Processor executable...
Property 'sonar.cs.vstest.reportsPaths' provided, skipping the search for TRX files in default folders...
Did not find any binary coverage files in the expected location.
Falling back on locating coverage files in the agent temp directory.
Searching for coverage files in D:\Agents\Agent-1\_work\_temp
No coverage files found in the agent temp directory.
Coverage report conversion completed successfully.
The TFS Processor has finished
Pipeline:
name: ###-Prebuild-and-Unit-Testing$(date:yyyyMMdd)$(rev:.r)
trigger:
branches:
include:
- main
- release/*
paths:
exclude:
- ReleaseNotes/*
pool:
name: 'Default'
variables:
solution: '**/*.sln'
buildPlatform: 'Any CPU'
buildConfiguration: 'Release'
stages:
- stage: UnitTests
displayName: "PreBuild, Unit Tests"
jobs:
- job:
displayName: "### Prebuild and Unit Testing"
timeoutInMinutes: 180
steps:
- task: DotNetCoreCLI@2
displayName: "DotNet Restore"
inputs:
command: 'restore'
projects: '$(solution)'
feedsToUse: 'select'
- task: SonarCloudPrepare@3.1.1
displayName: Prepare analysis configuration
inputs:
SonarQube: 'SonarCloud'
organization: '###'
scannerMode: 'dotnet'
projectKey: '###-backend'
projectName: '###-backend'
extraProperties: |
sonar.exclusions=**/obj/**,**/*.dll,**/*.sql,**/bin/**,**/*.xml,**/###.Data/**,**/lib/**
sonar.cs.opencover.reportsPaths=$(Agent.TempDirectory)/**/coverage.opencover.xml
sonar.cs.vstest.reportsPaths=$(Agent.TempDirectory)/*.trx
enabled: true
- task: DotNetCoreCLI@2
displayName: "DotNet Build"
inputs:
command: 'build'
projects: '$(solution)'
arguments: '-c $(buildConfiguration) --source https://api.nuget.org/v3/index.json'
- task: DotNetCoreCLI@2
displayName: "DotNet Test"
continueOnError: true
inputs:
command: test
projects: '**/*.Test/*.csproj'
arguments: '--configuration $(buildConfiguration)'
publishTestResults:: true
- task: SonarCloudAnalyze@3.1.1
displayName: SonarCloud - Run code analysis
- task: SonarCloudPublish@3.1.1
displayName: SonarCloud - Publish quality gate result
inputs:
pollingTimeoutSec: '300'
Thank you in advance for any help.