-
Notifications
You must be signed in to change notification settings - Fork 37
/
azure-pipelines.yml
230 lines (208 loc) · 7.99 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
schedules:
- cron: 0 10 * * *
displayName: Every day at 10:00 UTC
branches:
include:
- main
always: true
resources:
repositories:
- repository: 1ESPipelineTemplates
type: git
name: 1ESPipelineTemplates/1ESPipelineTemplates
ref: refs/tags/release
extends:
template: v1/1ES.Official.PipelineTemplate.yml@1ESPipelineTemplates
parameters:
pool:
name: NetCore1ESPool-Internal-XL
image: 1es-windows-2022
os: windows
customBuildTags:
- ES365AIMigrationTooling
stages:
- stage: stage
jobs:
- job: BuildIndex
displayName: Build Source Index
timeoutInMinutes: 360
variables:
- name: system.debug
value: true
- ${{ if and(ne(variables['System.TeamProject'], 'public'), notin(variables['Build.Reason'], 'PullRequest'), eq(variables['Build.SourceBranch'], 'refs/heads/main')) }}:
- name: isOfficialBuild
value: True
- name: deploymentSlot
value: staging
- name: storageAccount
value: netsourceindex
- ${{ else }}:
- name: isOfficialBuild
value: False
- name: deploymentSlot
value: validation
- name: storageAccount
value: netsourceindexvalidation
- group: source-dot-net stage1 variables
templateContext:
outputs:
- output: nuget
displayName: 'NuGet push'
packageParentPath: '$(Build.ArtifactStagingDirectory)'
packagesToPush: '$(Build.ArtifactStagingDirectory)/packages/*.nupkg'
nuGetFeedType: 'internal'
publishVstsFeed: '9ee6d478-d288-47f7-aacc-f6e6d082ae6d/d1622942-d16f-48e5-bc83-96f4539e7601'
- output: pipelineArtifact
condition: always()
targetPath: $(Build.ArtifactStagingDirectory)/logs
artifactName: logs
steps:
- checkout: self
clean: true
submodules: true
- task: DeleteFiles@1
displayName: Delete files from bin
inputs:
SourceFolder: bin
Contents: '**/*'
- task: UseDotNet@2
displayName: Install .NET Sdk
inputs:
useGlobalJson: true
- task: DotNetCoreCLI@2
displayName: dotnet restore
inputs:
command: custom
custom: restore
projects: |
**\*.sln
- task: DotNetCoreCLI@2
displayName: dotnet build
inputs:
command: 'build'
projects: |
src\source-indexer.sln
src\SourceBrowser\SourceBrowser.sln
arguments: '/p:PackageOutputPath=$(Build.ArtifactStagingDirectory)/packages'
- task: AzureCLI@2
displayName: Log in to Azure and clone data
inputs:
azureSubscription: 'SourceDotNet Stage1 Publish'
addSpnToEnvironment: true
scriptType: 'ps'
scriptLocation: 'inlineScript'
inlineScript: |
dotnet build build.proj /t:Clone /v:n /bl:$(Build.ArtifactStagingDirectory)/logs/clone.binlog /p:Stage1StorageAccount=netsourceindexstage1 /p:Stage1StorageContainer=stage1
- task: DotNetCoreCLI@2
displayName: Prepare All Repositories
inputs:
command: 'build'
projects: 'build.proj'
arguments: '/t:Prepare /v:n /bl:$(Build.ArtifactStagingDirectory)/logs/prepare.binlog'
- task: DotNetCoreCLI@2
displayName: Build source index
inputs:
command: 'build'
projects: 'build.proj'
arguments: '/t:BuildIndex /v:n /bl:$(Build.ArtifactStagingDirectory)/logs/build.binlog'
- task: CopyFiles@2
inputs:
sourceFolder: bin/index/
contents: |
**
!index/**
targetFolder: bin/index-stage/
cleanTargetFolder: true
- powershell: deployment/normalize-case.ps1 -Root bin/index/index/
displayName: Normalize Case Of Index Files
- task: AzureCLI@2
displayName: Create new storage container
inputs:
azureSubscription: SourceDotNet-Deployment-ARM
scriptLocation: inlineScript
scriptType: ps
inlineScript: >
deployment/upload-index-to-container.ps1
-StorageAccountName $(storageAccount)
-OutFile bin/index.url
- task: AzureFileCopy@6
displayName: Upload index to Azure Stroage
inputs:
azureSubscription: SourceDotNet-Deployment-ARM
SourcePath: "bin/index/index/*"
Destination: AzureBlob
storage: $(storageAccount)
ContainerName: $(NEW_CONTAINER_NAME)
- task: AzureRmWebAppDeployment@4
displayName: 'Azure App Service Deploy: netsourceindex'
inputs:
ConnectionType: AzureRM
azureSubscription: SourceDotNet-Deployment-ARM
appType: webApp
WebAppName: netsourceindex
ResourceGroupName: source.dot.net
deployToSlotOrASE: true
SlotName: $(deploymentSlot)
packageForLinux: bin/index-stage/
enableCustomDeployment: true
DeploymentType: zipDeploy
RemoveAdditionalFilesFlag: true
- task: AzureCLI@2
displayName: Deploy Storage Proxy Url to WebApp
inputs:
azureSubscription: SourceDotNet-Deployment-ARM
scriptLocation: inlineScript
scriptType: ps
inlineScript: >
deployment/deploy-storage-proxy.ps1
-ProxyUrlFile bin/index.url
-ResourceGroup source.dot.net
-WebappName netsourceindex
-Slot $(deploymentSlot)
- task: AzureCLI@2
displayName: Restart WebApp
inputs:
azureSubscription: SourceDotNet-Deployment-ARM
scriptLocation: inlineScript
scriptType: ps
inlineScript: |
az webapp restart --name netsourceindex --slot $(deploymentSlot) --resource-group source.dot.net
- pwsh: |
Start-Sleep 60
$urls = @(
"https://netsourceindex-$(deploymentSlot).azurewebsites.net",
"https://netsourceindex-$(deploymentSlot).azurewebsites.net/System.Private.CoreLib/src/libraries/System.Private.CoreLib/src/System/String.cs.html"
)
foreach ($url in $urls) {
$statusCode = Invoke-WebRequest $url -UseBasicParsing -SkipHttpErrorCheck | select -ExpandProperty StatusCode
if ($statusCode -ne 200) {
Write-Host "##vso[task.logissue type=error;]Deployed website returned undexpected status code $statusCode from url $url"
Write-Host "##vso[task.complete result=Failed;]Deployed website returned undexpected status code $statusCode from url $url"
}
}
displayName: Test Deployed WebApp
- task: AzureCLI@2
displayName: Swap Staging Slot into Production
condition: eq(variables['isOfficialBuild'], 'True')
inputs:
azureSubscription: SourceDotNet-Deployment-ARM
scriptLocation: inlineScript
scriptType: ps
inlineScript: >
az webapp deployment slot swap
--resource-group source.dot.net
--name netsourceindex
--slot staging
--target-slot production
- task: AzureCLI@2
displayName: Cleanup Old Storage Containers
condition: eq(variables['isOfficialBuild'], 'True')
inputs:
azureSubscription: SourceDotNet-Deployment-ARM
scriptLocation: inlineScript
scriptType: ps
inlineScript: >
deployment/cleanup-old-containers.ps1
-ResourceGroup source.dot.net
-WebappName netsourceindex
-StorageAccountName $(storageAccount)