forked from BEagle1984/silverback
-
Notifications
You must be signed in to change notification settings - Fork 0
/
azure-pipelines.sonar.yml
84 lines (79 loc) · 2.41 KB
/
azure-pipelines.sonar.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
name: sonar.$(date:yyyyMMdd)$(rev:.r)
trigger: none
pr: none
resources:
pipelines:
- pipeline: continuous
source: continuous
trigger:
branches:
- '*'
pool:
vmImage: 'ubuntu-20.04'
variables:
buildConfiguration: 'Release'
steps:
# Install .net core sdk
- task: UseDotNet@2
inputs:
packageType: 'sdk'
version: '2.2.x'
displayName: 'Install sdk 2.2.x'
- task: UseDotNet@2
inputs:
packageType: 'sdk'
version: '3.1.x'
displayName: 'Install sdk 3.1.x'
- task: UseDotNet@2
inputs:
packageType: 'sdk'
version: '5.0.x'
displayName: 'Install sdk 5.0.x'
# Build, test and analyze
- task: SonarCloudPrepare@1
inputs:
SonarCloud: 'Silverback SonarCloud'
organization: 'silverback'
scannerMode: 'MSBuild'
projectKey: 'silverback'
projectName: 'silverback'
projectVersion: '3.2.0'
extraProperties: |
sonar.exclusions=**/obj/**,**/*.dll
sonar.cs.opencover.reportsPaths=$(Build.SourcesDirectory)/**/coverage.opencover.xml
sonar.cs.vstest.reportsPaths=$(Agent.TempDirectory)/*.trx
displayName: 'Prepare code analysis on SonarCloud'
- script: |
dotnet build Silverback.sln --configuration $(buildConfiguration)
displayName: 'Build ($(buildConfiguration))'
- script: |
dotnet test Silverback.sln \
--configuration $(buildConfiguration) \
--no-build \
--verbosity Normal \
--logger trx \
--collect "Code coverage" \
--filter "CI!=false" \
-p:CollectCoverage=true \
-p:CoverletOutputFormat=opencover%2ccobertura \
-p:Exclude="[xunit.*]*%2c[Silverback.Tests.*]*"
displayName: 'Run tests'
- task: SonarCloudAnalyze@1
condition: succeededOrFailed()
displayName: 'Run SonarCloud analysis'
- task: SonarCloudPublish@1
condition: succeededOrFailed()
displayName: 'Publish SonarCloud quality gate result'
# Publish results
- task: PublishTestResults@2
condition: succeededOrFailed()
inputs:
testRunner: VSTest
testResultsFiles: '**/*.trx'
displayName: 'Publish test results'
- task: PublishCodeCoverageResults@1
condition: succeededOrFailed()
inputs:
summaryFileLocation: $(System.DefaultWorkingDirectory)/**/coverage.cobertura.xml
codecoverageTool: cobertura
displayName: 'Publish code coverage results'