-
-
Save Bigtalljosh/d9836612abdb884de61d9736a370f37f to your computer and use it in GitHub Desktop.
Medium-SonarSetup
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pool: | |
name: Azure Pipelines | |
variables: | |
BuildConfiguration: 'Release' | |
ShortVersion: '1.0.0' | |
steps: | |
- task: SonarSource.sonarcloud.14d9cde6-c1da-4d55-aa01-2965cd301255.SonarCloudPrepare@1 | |
displayName: 'Prepare analysis on SonarCloud' | |
inputs: | |
SonarCloud: 'My Project' | |
organization: MyOrganisation | |
projectKey: 'testproject' | |
projectName: 'My Project' | |
extraProperties: | | |
sonar.exclusions=**/obj/**,**/*.dll | |
sonar.cs.xunit.reportsPaths=${Agent.TempDirectory}/**/XUnit.TestResults.xml | |
sonar.cs.opencover.reportsPaths=${Agent.TempDirectory}/**/opencoverCoverage.xml | |
- task: DotNetCoreCLI@2 | |
displayName: Restore | |
inputs: | |
command: restore | |
projects: '**/*.csproj' | |
noCache: true | |
- task: DotNetCoreCLI@2 | |
displayName: Build | |
inputs: | |
projects: '**/*.csproj' | |
arguments: '--configuration $(BuildConfiguration) /property:Version=$(ShortVersion) --no-restore' | |
- task: DotNetCoreCLI@2 | |
displayName: Test | |
inputs: | |
command: test | |
projects: '**/*.Tests.csproj' | |
arguments: '--configuration $(BuildConfiguration) --no-build /p:CollectCoverage=true /p:CoverletOutputFormat=opencover /p:CoverletOutput=$(Agent.TempDirectory)/coverage/ /p:MergeWith=$(Agent.TempDirectory)/coverage/ --collect "Code coverage"' | |
- task: PublishTestResults@2 | |
displayName: "Publish Test Results" | |
inputs: | |
testResultsFormat: VSTest | |
testResultsFiles: "$(Agent.TempDirectory)/**.*trx" | |
mergeTestResults: true | |
condition: succeededOrFailed() | |
- task: SonarSource.sonarcloud.ce096e50-6155-4de8-8800-4221aaeed4a1.SonarCloudAnalyze@1 | |
displayName: 'Run Code Analysis' | |
- task: SonarSource.sonarcloud.38b27399-a642-40af-bb7d-9971f69712e8.SonarCloudPublish@1 | |
displayName: 'Publish Quality Gate Result' | |
# I would then package and publish the app |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment