Skip to content

Commit 1e1ba8b

Browse files
authored
Fix SonarCloud (#133)
* Fix SonarCloud * --
1 parent 0b446ec commit 1e1ba8b

File tree

1 file changed

+17
-21
lines changed

1 file changed

+17
-21
lines changed

azure-pipeline-ci.yml

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -12,37 +12,33 @@ steps:
1212
echo "BuildId = $(buildId)"
1313
displayName: 'Print buildId'
1414

15+
- script: |
16+
dotnet tool install --global dotnet-sonarscanner
17+
dotnet tool install --global dotnet-coverage
18+
displayName: 'Install dotnet tools'
19+
1520
- task: PowerShell@2
16-
displayName: "Use JDK11 by default"
21+
displayName: "Use JDK17 by default"
1722
inputs:
1823
targetType: 'inline'
1924
script: |
20-
$jdkPath = $env:JAVA_HOME_11_X64
25+
$jdkPath = $env:JAVA_HOME_17_X64
2126
Write-Host "##vso[task.setvariable variable=JAVA_HOME]$jdkPath"
2227
23-
- task: SonarCloudPrepare@1
24-
displayName: 'Prepare analysis on SonarCloud'
28+
- script: |
29+
dotnet sonarscanner begin /k:"Handlebars.Net.Helpers" /o:"stefh-github" /d:sonar.branch.name=$(Build.SourceBranchName) /d:sonar.host.url="https://sonarcloud.io" /d:sonar.token="$(SONAR_TOKEN)" /d:sonar.pullrequest.provider=github /d:sonar.cs.opencover.reportsPaths=**/coverage.net8.0.opencover.xml /d:sonar.verbose=true
30+
displayName: 'Begin analysis on SonarCloud'
2531
condition: and(succeeded(), eq(variables['RUN_SONAR'], 'yes'), ne(variables['Build.Reason'], 'PullRequest')) # Do not run for PullRequests
26-
inputs:
27-
SonarCloud: SonarCloud
28-
organization: stefh-github
29-
projectKey: 'Handlebars.Net.Helpers'
30-
projectName: 'Handlebars.Net.Helpers'
31-
extraProperties: |
32-
sonar.cs.opencover.reportsPaths=**/coverage.net6.0.opencover.xml
3332

34-
# Build source, tests and run tests for net452 and net6.0 (with coverage)
33+
# Build source, tests and run tests for net452 and net8.0 (with coverage)
3534
- script: |
3635
dotnet test ./test/Handlebars.Net.Helpers.Tests/Handlebars.Net.Helpers.Tests.csproj --configuration Debug --framework net452
37-
dotnet test ./test/Handlebars.Net.Helpers.Tests/Handlebars.Net.Helpers.Tests.csproj --configuration Debug --framework net6.0 --logger trx /p:CollectCoverage=true /p:CoverletOutputFormat=opencover
38-
displayName: 'Build source, tests and run tests for net452 and net6.0 (with coverage)'
36+
dotnet test ./test/Handlebars.Net.Helpers.Tests/Handlebars.Net.Helpers.Tests.csproj --configuration Debug --framework net8.0 --logger trx /p:CollectCoverage=true /p:CoverletOutputFormat=opencover
37+
displayName: 'Build source, tests and run tests for net452 and net8.0 (with coverage)'
3938

40-
- task: SonarCloudAnalyze@1
41-
displayName: 'SonarCloud: Run Code Analysis'
42-
condition: and(succeeded(), eq(variables['RUN_SONAR'], 'yes'), ne(variables['Build.Reason'], 'PullRequest')) # Do not run for PullRequests
43-
44-
- task: SonarCloudPublish@1
45-
displayName: 'SonarCloud: Publish Quality Gate Result'
39+
- script: |
40+
dotnet sonarscanner end /d:sonar.token="$(SONAR_TOKEN)"
41+
displayName: 'End analysis on SonarCloud'
4642
condition: and(succeeded(), eq(variables['RUN_SONAR'], 'yes'), ne(variables['Build.Reason'], 'PullRequest')) # Do not run for PullRequests
4743

4844
- task: whitesource.ws-bolt.bolt.wss.WhiteSource Bolt@19
@@ -51,7 +47,7 @@ steps:
5147

5248
# Upload coverage to codecov.io
5349
- script: |
54-
%USERPROFILE%\.nuget\packages\codecov\1.10.0\tools\codecov.exe -f "./test/Handlebars.Net.Helpers.Tests/coverage.net6.0.opencover.xml" -t $(CODECOV_TOKEN)
50+
%USERPROFILE%\.nuget\packages\codecov\1.10.0\tools\codecov.exe -f "./test/Handlebars.Net.Helpers.Tests/coverage.net8.0.opencover.xml" -t $(CODECOV_TOKEN)
5551
displayName: Upload coverage to codecov.io
5652

5753
# https://github.com/microsoft/azure-pipelines-tasks/issues/12212

0 commit comments

Comments
 (0)