-
Notifications
You must be signed in to change notification settings - Fork 0
/
azure-pipelines.yml
163 lines (161 loc) · 5.31 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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
trigger:
batch: true
branches:
include:
- '*'
pr:
branches:
include:
- '*'
stages:
- stage: Build
displayName: Build
variables:
- name: versionSuffix
value: ''
pool:
vmImage: ubuntu-latest
jobs:
- job: Build
displayName: Build
steps:
- task: Bash@3
displayName: Set Version Suffix
condition: and(succeeded(), ne(variables['Build.SourceBranch'], 'refs/heads/master'))
inputs:
targetType: inline
script: >
echo "##vso[task.setvariable variable=versionSuffix]ci-$BUILD_BUILDNUMBER"
- task: SonarCloudPrepare@1
displayName: Prepare analysis on SonarCloud
inputs:
SonarCloud: SonarCloud
organization: godeltech
scannerMode: MSBuild
projectKey: $(Build.DefinitionName)
projectName: $(Build.DefinitionName)
extraProperties: >
sonar.cs.opencover.reportsPaths="$(Agent.TempDirectory)/**/coverage.opencover.xml"
sonar.coverage.exclusions="tools/build/*"
- task: UseDotNet@2
displayName: Use .NET Core SDK
inputs:
packageType: sdk
version: 3.x
- task: DotNetCoreCLI@2
displayName: dotnet restore from both NuGet and Azure Artifacts feeds
condition: and(ne(variables['Build.SourceBranch'], 'refs/heads/master'), ne(variables['Build.Reason'], 'PullRequest'))
inputs:
command: restore
projects: '**/*.csproj'
feedsToUse: select
vstsFeed: 19324bbd-9baf-4407-b86d-3e7f0d145399/1574777e-9941-4b90-baa9-d9938266ac24
- task: DotNetCoreCLI@2
displayName: dotnet restore only from NuGet feed
condition: or(eq(variables['Build.SourceBranch'], 'refs/heads/master'), eq(variables['Build.Reason'], 'PullRequest'))
inputs:
command: restore
projects: '**/*.csproj'
feedsToUse: select
- task: DotNetCoreCLI@2
displayName: dotnet build
inputs:
command: build
projects: '**/*.csproj'
arguments: --configuration Release /p:VersionSuffix=$(versionSuffix)
- task: DotNetCoreCLI@2
displayName: dotnet test
inputs:
command: test
projects: '**/*[Tt]ests/*.csproj'
arguments: --configuration Release --settings $(System.DefaultWorkingDirectory)/CodeCoverage.runsettings --collect:"XPlat Code Coverage" -- RunConfiguration.DisableAppDomain=true
- task: DotNetCoreCLI@2
displayName: Install ReportGenerator tool
inputs:
command: custom
custom: tool
arguments: install --tool-path . dotnet-reportgenerator-globaltool
- task: CmdLine@2
displayName: Create reports
inputs:
script: ./reportgenerator -reports:$(Agent.TempDirectory)/**/coverage.cobertura.xml -targetdir:$(Build.SourcesDirectory)/coverlet/reports -reporttypes:"Cobertura"
- task: PublishCodeCoverageResults@1
displayName: Publish code coverage
inputs:
codeCoverageTool: Cobertura
summaryFileLocation: $(Build.SourcesDirectory)/coverlet/reports/Cobertura.xml
- task: UseDotNet@2
displayName: Use .NET Core SDK 2.2.x for SonarCloud
inputs:
packageType: sdk
version: 2.2.x
- task: SonarCloudAnalyze@1
displayName: Run Code Analysis
- task: SonarCloudPublish@1
displayName: Publish Quality Gate Result
inputs:
pollingTimeoutSec: 300
- task: sonarcloud-buildbreaker@2
displayName: Break build on quality gate failure
condition: eq(True, true)
inputs:
SonarCloud: SonarCloud
organization: godeltech
- task: DotNetCoreCLI@2
displayName: Pack .NET Core NuGet packages
inputs:
command: pack
packagesToPack: '**/*.csproj'
buildProperties: VersionSuffix=$(versionSuffix)
packDirectory: $(Build.ArtifactStagingDirectory)/packages
versioningScheme: off
- task: PublishPipelineArtifact@1
displayName: 'Publish Pipeline Artifact: NuGet Packages'
inputs:
path: $(Build.ArtifactStagingDirectory)/packages
artifact: NuGet Packages
- stage: Artifacts
displayName: Artifacts
dependsOn:
- Build
pool:
vmImage: ubuntu-latest
jobs:
- deployment: Publish
displayName: Publish packages in Artifacts
environment:
name: Artifacts
strategy:
runOnce:
deploy:
steps:
- task: NuGetCommand@2
displayName: Push package in Artifacts
inputs:
command: push
packagesToPush: $(Pipeline.Workspace)/**/*.nupkg;!$(Pipeline.Workspace)/**/*.symbols.nupkg
nuGetFeedType: internal
publishVstsFeed: 19324bbd-9baf-4407-b86d-3e7f0d145399/1574777e-9941-4b90-baa9-d9938266ac24
- stage: NuGet
displayName: NuGet
dependsOn:
- Artifacts
condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/master'))
pool:
vmImage: ubuntu-latest
jobs:
- deployment: Publish
displayName: Publish packages
environment:
name: NuGet
strategy:
runOnce:
deploy:
steps:
- task: NuGetCommand@2
displayName: NuGet push
inputs:
command: push
packagesToPush: $(Pipeline.Workspace)/**/*.nupkg;!$(Pipeline.Workspace)/**/*.symbols.nupkg
nuGetFeedType: external
publishFeedCredentials: NuGet