Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use dotnet sonar scanner (part 2) #1125

Merged
merged 17 commits into from
Jun 20, 2024
Prev Previous commit
Next Next commit
FIX
  • Loading branch information
StefH committed Jun 20, 2024
commit f229e2c27c8bd735fda0d3b7b2afae30a3f1d962
35 changes: 12 additions & 23 deletions azure-pipelines-ci.yml
Original file line number Diff line number Diff line change
@@ -14,53 +14,42 @@ jobs:
echo "BuildId = $(buildId)"
displayName: 'Print buildId'

- task: UseDotNet@2
displayName: Use .NET 8.0
inputs:
packageType: 'sdk'
version: '8.0.x'
- script: |
dotnet tool install --global dotnet-sonarscanner
displayName: 'Install SonarScanner tool'

- task: PowerShell@2
displayName: "Use JDK11 by default"
displayName: "Use JDK17 by default"
inputs:
targetType: 'inline'
script: |
$jdkPath = $env:JAVA_HOME_11_X64
$jdkPath = $env:JAVA_HOME_17_X64
Write-Host "##vso[task.setvariable variable=JAVA_HOME]$jdkPath"

- script: |
dotnet dev-certs https --trust || true
displayName: 'dotnet dev-certs https'

- task: SonarCloudPrepare@1
displayName: 'Prepare analysis on SonarCloud'
- script: |
dotnet sonarscanner begin /k:"WireMock-Net_WireMock.Net" /o:"wiremock-net" /d:sonar.branch.name=$(Build.SourceBranchName) /d:sonar.host.url="https://sonarcloud.io" /d:sonar.token="$(SONAR_TOKEN)" /d:sonar.dotnet.excludeTestProjects=true /d:sonar.cs.opencover.reportsPaths=**/coverage.net8.0.opencover.xml /d:sonar.verbose=true
displayName: 'Begin analysis on SonarCloud'
condition: and(succeeded(), ne(variables['Build.Reason'], 'PullRequest')) # Do not run for PullRequests
inputs:
SonarCloud: SonarCloud
organization: wiremock-net
projectKey: 'WireMock-Net_WireMock.Net'
projectName: 'WireMock.Net'
extraProperties: |
sonar.cs.opencover.reportsPaths=**/coverage.net8.0.opencover.xml

- task: DotNetCoreCLI@2
displayName: 'Build Unit tests'
inputs:
command: 'build'
projects: './test/WireMock.Net.Tests/WireMock.Net.Tests.csproj'
arguments: '--configuration Debug --framework net8.0'
arguments: '--configuration Debug --framework net8.0 --no-incremental'

- task: CmdLine@2
inputs:
script: 'dotnet test ./test/WireMock.Net.Tests/WireMock.Net.Tests.csproj --no-build --configuration Debug --framework net8.0'
displayName: 'Execute Unit Tests with Coverage'

- task: SonarCloudAnalyze@1
displayName: 'SonarCloud: Run Code Analysis'
condition: and(succeeded(), ne(variables['Build.Reason'], 'PullRequest')) # Do not run for PullRequests

- task: SonarCloudPublish@1
displayName: 'SonarCloud: Publish Quality Gate Result'
- script: |
dotnet sonarscanner end /d:sonar.token="$(SONAR_TOKEN)"
displayName: 'End analysis on SonarCloud'
condition: and(succeeded(), ne(variables['Build.Reason'], 'PullRequest')) # Do not run for PullRequests

- task: whitesource.ws-bolt.bolt.wss.WhiteSource Bolt@19