-
Notifications
You must be signed in to change notification settings - Fork 2
/
azure-pipelines.yml
106 lines (90 loc) · 3.81 KB
/
azure-pipelines.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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
trigger:
branches:
include:
- master
- rel/v*
paths:
include:
- '*'
exclude:
- 'doc/*'
- '*.md'
pool:
vmImage: 'windows-latest'
variables:
- group: common
- name: buildConfiguration
value: Release
- name: DOTNET_SKIP_FIRST_TIME_EXPERIENCE
value: true
- name: sonarProjectKey
value: 'iron9light_FluentValidation.Extensions'
- name: sonarPullrequestGithubRepository
value: 'iron9light/FluentValidation.Extensions'
steps:
- task: UseDotNet@2
displayName: 'Use .NET 7'
inputs:
packageType: sdk
version: 7.x
- script: dotnet tool install --tool-path . nbgv
displayName: 'Install NBGV tool'
- script: nbgv cloud
displayName: Set Version
- script: dotnet tool install --tool-path . dotnet-sonarscanner
displayName: 'Install SonarScanner tool'
- script: dotnet-sonarscanner begin /k:"$(sonarProjectKey)" /o:"iron9light-github" /v:"$(Build.BuildNumber)" /d:sonar.host.url="https://sonarcloud.io" /d:sonar.login="$(sonar.token)" /d:sonar.cs.opencover.reportsPaths="$(Build.SourcesDirectory)/**/coverage.opencover.xml" /d:sonar.cs.vstest.reportsPaths="$(Agent.TempDirectory)/*.trx" /d:sonar.pullrequest.key=$(System.PullRequest.PullRequestNumber) /d:sonar.pullrequest.branch="$(System.PullRequest.SourceBranch)" /d:sonar.pullrequest.base="$(System.PullRequest.TargetBranch)" /d:sonar.pullrequest.github.repository="$(sonarPullrequestGithubRepository)"
displayName: 'SonarScanner begin (PR)'
condition: and(succeeded(), variables['System.PullRequest.SourceBranch'])
- script: dotnet-sonarscanner begin /k:"$(sonarProjectKey)" /o:"iron9light-github" /v:"$(Build.BuildNumber)" /d:sonar.host.url="https://sonarcloud.io" /d:sonar.login="$(sonar.token)" /d:sonar.cs.opencover.reportsPaths="$(Build.SourcesDirectory)/**/coverage.opencover.xml" /d:sonar.cs.vstest.reportsPaths="$(Agent.TempDirectory)/*.trx" /d:sonar.branch.name="$(Build.SourceBranchName)"
displayName: 'SonarScanner begin'
condition: and(succeeded(), not(variables['System.PullRequest.SourceBranch']))
- script: dotnet build --configuration $(buildConfiguration) -p:RepositoryBranch="$(Build.SourceBranchName)"
displayName: 'dotnet build $(buildConfiguration)'
workingDirectory: src
- task: DotNetCoreCLI@2
displayName: 'dotnet test $(buildConfiguration)'
inputs:
command: test
projects: '**/*.sln'
arguments: '--configuration $(buildConfiguration) --no-build /p:CollectCoverage=true'
workingDirectory: src
- task: JavaToolInstaller@0
displayName: 'install Java 11 for sonarscanner'
inputs:
versionSpec: "11"
jdkArchitectureOption: 'x64'
jdkSourceOption: 'PreInstalled'
- script: dotnet-sonarscanner end /d:sonar.login="$(sonar.token)"
displayName: 'SonarScanner end'
- task: PublishCodeCoverageResults@1
displayName: Publish Coverage
inputs:
codeCoverageTool: cobertura
summaryFileLocation: $(Build.SourcesDirectory)/**/coverage.cobertura.xml
- task: DotNetCoreCLI@2
displayName: Pack
inputs:
command: pack
packagesToPack: '**/*.csproj'
configuration: $(BuildConfiguration)
packDirectory: $(Build.ArtifactStagingDirectory)/artifacts
nobuild: true
verbosityPack: Minimal
condition: and(succeeded(), not(variables['System.PullRequest.SourceBranch']))
- task: PublishBuildArtifacts@1
displayName: Publish Package Artifacts
inputs:
pathToPublish: $(Build.ArtifactStagingDirectory)/artifacts
artifactType: container
artifactName: Packages
condition: and(succeeded(), not(variables['System.PullRequest.SourceBranch']))
- task: NuGetCommand@2
displayName: 'GitHub packages NuGet push'
inputs:
command: push
packagesToPush: '$(Build.ArtifactStagingDirectory)/**/*.nupkg'
nuGetFeedType: external
publishFeedCredentials: GitHubPackagesNuGetConnection
condition: and(succeeded(), not(variables['System.PullRequest.SourceBranch']))
continueOnError: true