@@ -27,7 +27,7 @@ parameters:
2727
2828 - name : shouldRunUnitTests
2929 displayName : ' Flag should run unit tests'
30- default : ' true'
30+ default : true
3131 type : boolean
3232
3333 - name : shouldRunIntegrationTests
@@ -36,7 +36,7 @@ parameters:
3636
3737 - name : integrationTestsProjectPath
3838 displayName : ' Integration tests project path'
39- type : string
39+ type : boolean
4040
4141 - name : gitVersionVersion
4242 displayName : ' GitVersion version'
@@ -72,6 +72,11 @@ parameters:
7272 default : ' https://auth.eventtriangle.razumovsky.me/'
7373 type : string
7474
75+ - name : sonarCloudEnabled
76+ displayName : ' Is SonarCloud scan enabled'
77+ default : false
78+ type : boolean
79+
7580jobs :
7681 - job : ${{ parameters.JobName }}
7782 displayName : ${{ parameters.JobName }}
@@ -102,22 +107,44 @@ jobs:
102107 arguments : ' --verbosity minimal'
103108 nugetConfigPath : ' nuget.config'
104109
110+ - ${{ if eq(parameters.sonarCloudEnabled, true) }} :
111+ - task : SonarCloudPrepare@4
112+ inputs :
113+ SonarCloud : SonarCloud_Service_Connection
114+ organization : event-triangle
115+ scannerMode : dotnet
116+ projectKey : event-triangle_eventtriangleapi
117+ projectName : eventtriangleapi
118+ extraProperties : |
119+ sonar.cs.vstest.reportsPaths=$(Agent.TempDirectory)/**/*.trx
120+ sonar.cs.opencover.reportsPaths=$(Agent.TempDirectory)/**/*opencover.xml
121+ sonar.exclusions=**/Properties/**, **/bin/**, **/obj/**, **/Migrations/**
122+
105123 - task : DotNetCoreCLI@2
106124 displayName : ' Build solution'
107125 inputs :
108126 command : ' build'
109127 projects : ' ${{ parameters.solution }}'
110128 arguments : ' -c ${{ parameters.buildConfiguration }} -p:Version=$(version_step.semVer) --no-restore'
111129
112- - ${{ if eq(parameters.shouldRunUnitTests, 'true') }} :
130+ - ${{ if eq(parameters.sonarCloudEnabled, true) }} :
131+ - task : SonarCloudAnalyze@4
132+ inputs : {}
133+
134+ - ${{ if eq(parameters.sonarCloudEnabled, true) }} :
135+ - task : SonarCloudPublish@4
136+ inputs :
137+ pollingTimeoutSec : " 300"
138+
139+ - ${{ if eq(parameters.shouldRunUnitTests, true) }} :
113140 - task : DotnetCoreCLI@2
114141 displayName : ' Run unit tests'
115142 inputs :
116143 command : ' test'
117144 projects : ' ${{ parameters.unitTestsProjectPath }}'
118145 arguments : ' --no-build --configuration ${{ parameters.buildConfiguration }} --collect "Code Coverage"'
119146
120- - ${{ if eq(parameters.shouldRunIntegrationTests, ' true' ) }} :
147+ - ${{ if eq(parameters.shouldRunIntegrationTests, true) }} :
121148 - task : DotNetCoreCLI@2
122149 displayName : ' Run integration tests'
123150 inputs :
0 commit comments