I have an Azure DevOps Git repo configured with a protected main
branch. The protection is set to run an Azure DevOps pipeline that calls SonarQube, the core bit of YAML is below
- task: SonarQubePrepare@4
inputs:
SonarQube: 'SonarQube'
scannerMode: 'MSBuild'
projectKey: '$(SonarQubeProjectKey)'
projectName: '$(SonarQubeName)'
projectVersion: '$(GitVersion.Major).$(GitVersion.Minor)'
extraProperties: |
# Additional properties that will be passed to the scanner,
# Put one key=value per line, example:
sonar.dependencyCheck.reportPath=$(Build.SourcesDirectory)/dependency-check-report.xml
sonar.dependencyCheck.htmlReportPath=$(Build.SourcesDirectory)/dependency-check-report.html
sonar.cpd.exclusions=**/AssemblyInfo.cs,**/*.g.cs
sonar.cs.vscoveragexml.reportsPaths=$(System.DefaultWorkingDirectory)/**/*.coveragexml
sonar.cs.vstest.reportsPaths=$(System.DefaultWorkingDirectory)/**/*.trx
- task: DotNetCoreCLI@2
displayName: 'Build the dotnet projects'
inputs:
command: 'build'
projects: '$(Build.SourcesDirectory)/src/**/*.csproj'
- task: VisualStudioTestPlatformInstaller@1
displayName: 'Install VSTest'
inputs:
packageFeedSelector: 'nugetOrg'
versionSelector: 'latestPreRelease'
- task: VSTest@2
displayName: 'Run VSTest'
inputs:
testSelector: 'testAssemblies'
testAssemblyVer2: |
**\*UnitTests.dll
!**\*TestAdapter.dll
!**\obj\**
searchFolder: '$(Build.SourcesDirectory)/src'
resultsFolder: '$(System.DefaultWorkingDirectory)\TestResults'
runInParallel: true
codeCoverageEnabled: true
rerunFailedTests: true
runTestsInIsolation: true
runOnlyImpactedTests: false
- task: CodeCoverage-Format-Convertor@1
displayName: 'Convert code coverage file to XML format'
inputs:
ProjectDirectory: '$(Build.SourcesDirectory)'
- task: SonarQubeAnalyze@4
- task: SonarQubePublish@4
inputs:
pollingTimeoutSec: '300'
When I create a PR, the pipeline is running and SonarQube finds issues, as expected.
SonarQube decoration is setup and is working, I can see the SonarQube issues in PR comments.
My question is about the PR showing an optional check that the SonarQube ‘Quality Check’ failed.
Can I make it so that the ‘Quality Check’ is a required PR check?
If it is in the documentation I cannot find it.