forked from dotnet/arcade-services
-
Notifications
You must be signed in to change notification settings - Fork 0
/
azure-pipelines.yml
261 lines (232 loc) · 11.5 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
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
variables:
# Cannot use key:value syntax in root defined variables
- name: _TeamName
value: DotNetCore
- name: _PublishUsingPipelines
value: true
- name: _DotNetArtifactsCategory
value: .NETCore
- ${{ if and(ne(variables['System.TeamProject'], 'public'), notin(variables['Build.Reason'], 'PullRequest')) }}:
- group: SDL_Settings
# CI and PR triggers
trigger:
batch: true
branches:
include:
- main
- production
pr:
- main
- production
pool:
name: NetCore1ESPool-Internal-NoMSI
demands: ImageOverride -equals 1es-windows-2019
stages:
- ${{ if eq(variables['Build.Reason'], 'PullRequest') }}:
- stage: GitHub_Issue_Verification
displayName: GitHub Issue Verification
dependsOn: []
# System.PullRequest.TargetBranch only evaulates during runtime conditions
condition: and(notIn(variables['System.PullRequest.TargetBranch'], 'refs/heads/production', 'production'), notIn(variables['System.PullRequest.SourceBranch'], 'refs/heads/production', 'production'))
jobs:
- job: VerifyGitHubIssue
displayName: Verify GitHub Issue Link included in all PRs
pool:
vmImage: windows-latest
steps:
- checkout: self
- powershell: eng/enforce-issue.ps1 -PullRequestNumber $(System.PullRequest.PullRequestNumber) -RepositoryName $(Build.Repository.Name)
displayName: Enforce GitHub issue link presence
- stage: build
dependsOn: []
displayName: Build
jobs:
- template: /eng/common/templates/jobs/jobs.yml
parameters:
${{ if in(variables['Build.SourceBranch'], 'refs/heads/main', 'refs/heads/production') }}:
enablePublishBuildArtifacts: true
enablePublishBuildAssets: true
${{ else }}:
enablePublishBuildArtifacts: false
enablePublishBuildAssets: false
enableMicrobuild: false
enablePublishTestResults: false
enablePublishUsingPipelines: ${{ variables._PublishUsingPipelines }}
enableTelemetry: true
helixRepo: dotnet/arcade-services
jobs:
- job: Windows_NT
timeoutInMinutes: 90
pool:
${{ if eq(variables['System.TeamProject'], 'internal')}}:
name: NetCore1ESPool-Internal
demands: ImageOverride -equals 1es-windows-2019
${{ if eq(variables['System.TeamProject'], 'public')}}:
name: NetCore-Public
demands: ImageOverride -equals 1es-windows-2019-open
variables:
- _InternalBuildArgs: ''
- _ProductionArgs: ''
# Only enable publishing in non-public, non PR scenarios.
- ${{ if and(ne(variables['System.TeamProject'], 'public'), notin(variables['Build.Reason'], 'PullRequest')) }}:
# DotNet-Blob-Feed provides: dotnetfeed-storage-access-key-1
# DotNet-Symbol-Server-Pats provides: microsoft-symbol-server-pat, symweb-symbol-server-pat
# Publish-Build-Assets provides: MaestroAccessToken, BotAccount-dotnet-maestro-bot-PAT
- group: DotNet-Blob-Feed
- group: DotNet-Symbol-Server-Pats
- group: Publish-Build-Assets
- _PublishBlobFeedUrl: https://dotnetfeed.blob.core.windows.net/dotnet-core/index.json
- _InternalBuildArgs: /p:DotNetSignType=$(_SignType) /p:TeamName=$(_TeamName)
/p:DotNetPublishBlobFeedKey=$(dotnetfeed-storage-access-key-1)
/p:DotNetPublishBlobFeedUrl=$(_PublishBlobFeedUrl)
/p:DotNetPublishToBlobFeed=$(_DotNetPublishToBlobFeed)
/p:DotNetPublishUsingPipelines=$(_PublishUsingPipelines)
/p:DotNetArtifactsCategory=$(_DotNetArtifactsCategory)
/p:DotNetSymbolServerTokenMsdl=$(microsoft-symbol-server-pat)
/p:DotNetSymbolServerTokenSymWeb=$(symweb-symbol-server-pat)
/p:OfficialBuildId=$(BUILD.BUILDNUMBER)
strategy:
matrix:
# Only build debug in non-official builds
${{ if or(eq(variables['System.TeamProject'], 'public'), in(variables['Build.Reason'], 'PullRequest')) }}:
debug_configuration:
_BuildConfig: Debug
_PublishType: none
_SignType: test
_DotNetPublishToBlobFeed : false
release_configuration:
_BuildConfig: Release
# PRs or external builds are not signed.
${{ if or(eq(variables['System.TeamProject'], 'public'), in(variables['Build.Reason'], 'PullRequest')) }}:
_PublishType: none
_SignType: test
_DotNetPublishToBlobFeed : false
${{ if and(ne(variables['System.TeamProject'], 'public'), notin(variables['Build.Reason'], 'PullRequest')) }}:
_PublishType: blob
_SignType: test
_DotNetPublishToBlobFeed : true
steps:
- checkout: self
clean: true
- task: NodeTool@0
displayName: Install node.js
inputs:
versionSpec: 12.x
- task: NuGetToolInstaller@0
displayName: Install NuGet
inputs:
versionSpec: 6.1.x
- task: NuGetCommand@2
displayName: Restore Packages
inputs:
command: restore
solution: "**/*.sln"
feedstoUse: config
- powershell: eng\set-version-parameters.ps1
displayName: Calculate Release Versions
- powershell: |
[xml]$manifest = Get-Content src\Maestro\MaestroApplication\ApplicationPackageRoot\ApplicationManifest.xml
$manifest.SelectSingleNode("/*[local-name()='ApplicationManifest']/*[local-name()='Policies']").RemoveAll()
$manifest.SelectSingleNode("/*[local-name()='ApplicationManifest']/*[local-name()='Principals']").RemoveAll()
$manifest.Save("src\Maestro\MaestroApplication\ApplicationPackageRoot\ApplicationManifest.xml")
git diff
displayName: Remove RunAsPolicy From MaestroApplication
- script: eng\common\cibuild.cmd
-configuration $(_BuildConfig)
-prepareMachine
$(_InternalBuildArgs)
$(_ProductionArgs)
/p:Test=false
/P:Sign=false
name: Build
- ${{ if and(ne(variables['System.TeamProject'], 'public'), notin(variables['Build.Reason'], 'PullRequest')) }}:
- task: ComponentGovernanceComponentDetection@0
displayName: Component Governance Detection
inputs:
# `.packages` directory is used by some tools running during build.
# By default ComponentDetection scans this directory and sometimes reports
# vulnerabilities for packages that are not part of the published product.
# We can ignore this directory because actual vulnerabilities
# that we are interested in will be found by the tool
# when scanning .csproj and package.json files.
ignoreDirectories: .packages
- ${{ if in(variables['Build.Reason'], 'PullRequest') }}:
- template: /eng/templates/steps/test.yml
- ${{ if and(ne(variables['System.TeamProject'], 'public'), notin(variables['Build.Reason'], 'PullRequest')) }}:
## Prepare service fabric artifact
- task: ServiceFabricUpdateManifests@2
displayName: Update Service Fabric manifests
inputs:
applicationPackagePath: $(Build.ArtifactStagingDirectory)\ServiceFabric\MaestroApplication\applicationpackage
- powershell: |
robocopy src/Maestro/MaestroApplication/PublishProfiles $(Build.ArtifactStagingDirectory)\ServiceFabric\MaestroApplication\projectartifacts\PublishProfiles /S *.xml
robocopy src/Maestro/MaestroApplication/ApplicationParameters $(Build.ArtifactStagingDirectory)\ServiceFabric\MaestroApplication\projectartifacts\ApplicationParameters /S *.xml
robocopy src/Maestro/MaestroApplication/ApplicationPackageRoot $(Build.ArtifactStagingDirectory)\ServiceFabric\MaestroApplication\projectartifacts\ApplicationPackageRoot /S *.xml
exit 0
displayName: Copy Maestro Project Artifacts
- publish: $(Build.ArtifactStagingDirectory)\ServiceFabric\MaestroApplication
artifact: MaestroApplication
displayName: Publish MaestroApplication
## Generate SBOM manifest
- template: /eng/templates/steps/generate-sbom.yml
## Prepare database update artifact
- script: $(Build.SourcesDirectory)\.dotnet\dotnet publish -o $(Build.ArtifactStagingDirectory)\Maestro.Data -f net6.0
workingDirectory: src/Maestro/Maestro.Data
displayName: Create Data Package
- task: CopyFiles@2
displayName: Copy update-database.ps1
inputs:
sourceFolder: $(Build.SourcesDirectory)\src\Maestro
contents: update-database.ps1
targetFolder: $(Build.ArtifactStagingDirectory)\Maestro.Data\
- publish: $(Build.ArtifactStagingDirectory)\Maestro.Data
artifact: Maestro.Data
displayName: Publish Maestro.Data Artifact
## Prepare release utilities artifact
- task: CopyFiles@2
displayName: Prepare Release Utilities
inputs:
sourceFolder: $(Build.SourcesDirectory)\eng
contents: '*'
targetFolder: $(Build.ArtifactStagingDirectory)\eng
- publish: $(Build.ArtifactStagingDirectory)\eng
artifact: ReleaseUtilities
displayName: Publish Release Utilities Artifact
- publish: $(Build.SourcesDirectory)\artifacts\bin\Maestro.ScenarioTests\$(_BuildConfig)\net6.0\publish
artifact: Maestro.ScenarioTests
displayName: Publish Maestro Scenario Tests
- ${{ if and(ne(variables['System.TeamProject'], 'public'), notin(variables['Build.Reason'], 'PullRequest'), in(variables['Build.SourceBranch'], 'refs/heads/main', 'refs/heads/production'))}}:
- template: /eng/common/templates/post-build/post-build.yml
parameters:
enableSymbolValidation: true
enableSigningValidation: false
artifactsPublishingAdditionalParameters: '/p:CheckEolTargetFramework=false'
symbolPublishingAdditionalParameters: '/p:CheckEolTargetFramework=false'
# This is to enable SDL runs part of Post-Build Validation Stage
SDLValidationParameters:
enable: true
params: '-SourceToolsList @("policheck","credscan")
-TsaInstanceURL $(_TsaInstanceURL)
-TsaProjectName $(_TsaProjectName)
-TsaNotificationEmail $(_TsaNotificationEmail)
-TsaCodebaseAdmin $(_TsaCodebaseAdmin)
-TsaBugAreaPath $(_TsaBugAreaPath)
-TsaIterationPath $(_TsaIterationPath)
-TsaRepositoryName "Arcade-Services"
-TsaCodebaseName "Arcade-Services"
-TsaPublish $True
-PoliCheckAdditionalRunConfigParams @("UserExclusionPath < $(Build.SourcesDirectory)/eng/PoliCheckExclusions.xml")'
- template: /eng/templates/stages/deploy.yaml
parameters:
${{ if ne(variables['Build.SourceBranch'], 'refs/heads/production') }}:
DeploymentEnvironment: Staging
MaestroTestEndpoint: https://maestro-int.westus2.cloudapp.azure.com
PublishProfile: Int
Subscription: NetHelixStaging
VariableGroup: MaestroInt KeyVault
${{ if eq(variables['Build.SourceBranch'], 'refs/heads/production') }}:
DeploymentEnvironment: Production
MaestroTestEndpoint: https://maestro-prod.westus2.cloudapp.azure.com
PublishProfile: Prod
Subscription: NetHelix
VariableGroup: MaestroProd KeyVault