- ALM: Azure DevOps
- CI: Azure DevOps
- Scanner command used: dotnet
- Languages: c#, TypeScript, JavaScript
Hello,
I have a repository with multiple dotnet solutions and want to build them individually. These services also contains some typescript and javascript.
Structure of the git repository:
/src/Pipelines/
/src/services/ScExampleService
/src/services/ScExample1Service
/src/services/ScExample2Service
/src/Pipelines/Pipeline.yml
Each solution is mapped to a project in sonar qube cloud and I only like to see the code for each solution in the project it belongs to, so for the SonarQube Prepare step I use the “sonar.projectBaseDir” property
I have added a PAT token for AzureDevOps to the project in SC
- task: SonarCloudPrepare@3
displayName: "SonarQube Cloud Prepare"
inputs:
SonarCloud: SonarCloud
organization: XXX
scannerMode: 'dotnet'
projectKey: some_key
projectName: SonarCloudTest
projectVersion: "$(Build.BuildNumber)"
extraProperties: |
sonar.projectBaseDir=$(Pipeline.Workspace)/s/src/Services/ScExampleService
sonar.verbose=true
When I then create a Pull Request and have an issue in that which is found by the scanner, then the PR is decorated with an issue that is relative to the project folder and therefore not mapped correctly in AzureDevOps, example from the PR:
[MyClass.cs]
/ScExampleService/MyClass.cs
This file no longer exists in the latest pull request changes. It may have been moved or deleted.
How can I make sure that the dotnet scanner only scans the project which is build and still be able to have PR comments that points correctly to the file?
I feel I am missing something basic here, can you advise?
Full pipeline steps:
- task: UseDotNet@2
displayName: 'Install .NET Core SDK'
inputs:
version: 8.x
- task: SonarCloudPrepare@3
displayName: "SonarQube Cloud Prepare"
inputs:
SonarCloud: SonarCloud
organization: XXX
scannerMode: 'dotnet'
projectKey: some_key
projectName: SonarCloudTest
projectVersion: "$(Build.BuildNumber)"
extraProperties: |
sonar.projectBaseDir=$(Pipeline.Workspace)/s/src/Services/ScExampleService
sonar.verbose=true
- task: DotNetCoreCLI@2
inputs:
command: 'restore'
projects: '$(Pipeline.Workspace)/s/src/Services/ScExampleService/**/*.csproj'
- task: DotNetCoreCLI@2
displayName: Build
inputs:
command: build
projects: '$(Pipeline.Workspace)/s/src/Services/ScExampleService/**/*.csproj'
arguments: '--configuration $(buildConfiguration)'
- task: SonarCloudAnalyze@3
displayName: "SonarQube Cloud Analyze"
inputs:
jdkversion: 'JAVA_HOME_17_X64'
- task: SonarCloudPublish@3
displayName: "SonarQube Cloud Publish"
inputs:
pollingTimeoutSec: '30'
Thanks
Mikkel