forked from dotnet/dotnet-buildtools-prereqs-docker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpublish.yml
More file actions
286 lines (257 loc) · 10.8 KB
/
Copy pathpublish.yml
File metadata and controls
286 lines (257 loc) · 10.8 KB
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
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
parameters:
pool: {}
internalProjectName: null
customInitSteps: []
customPublishVariables: []
sourceBuildPipelineDefinitionId: ""
sourceBuildPipelineRunId: ""
jobs:
- job: Publish
pool: ${{ parameters.pool }}
timeoutInMinutes: 90
variables:
- name: imageBuilder.commonCmdArgs
value: >-
--manifest '$(manifest)'
--registry-override '$(acr.server)'
$(manifestVariables)
$(imageBuilder.queueArgs)
- name: publishNotificationRepoName
value: $(Build.Repository.Name)
- name: branchName
${{ if startsWith(variables['Build.SourceBranch'], 'refs/heads/') }}:
value: $[ replace(variables['Build.SourceBranch'], 'refs/heads/', '') ]
${{ if startsWith(variables['Build.SourceBranch'], 'refs/pull/') }}:
value: $[ replace(variables['System.PullRequest.SourceBranch'], 'refs/heads/', '') ]
- name: imageInfoHostDir
value: $(Build.ArtifactStagingDirectory)/imageInfo
- name: imageInfoContainerDir
value: $(artifactsPath)/imageInfo
- name: sourceBuildIdOutputDir
value: $(Build.ArtifactStagingDirectory)/sourceBuildId
- ${{ parameters.customPublishVariables }}
steps:
- template: /eng/common/templates/steps/retain-build.yml@self
- template: /eng/common/templates/steps/init-docker-linux.yml@self
- pwsh: |
$azdoOrgName = Split-Path -Leaf $Env:SYSTEM_COLLECTIONURI
echo "##vso[task.setvariable variable=azdoOrgName]$azdoOrgName"
displayName: Set Publish Variables
- ${{ parameters.customInitSteps }}
- template: /eng/common/templates/steps/validate-branch.yml@self
parameters:
internalProjectName: ${{ parameters.internalProjectName }}
- template: /eng/common/templates/steps/download-build-artifact.yml@self
parameters:
targetPath: $(imageInfoHostDir)
artifactName: image-info
piplineDefinitionId: ${{ parameters.sourceBuildPipelineDefinitionId }}
pipelineRunId: ${{ parameters.sourceBuildPipelineRunId }}
# This can fail in scenarios where no build jobs have run to produce any artifacts
continueOnError: true
- template: /eng/common/templates/steps/set-image-info-path-var.yml@self
parameters:
publicSourceBranch: $(publicSourceBranch)
- template: /eng/common/templates/steps/set-dry-run.yml@self
- script: echo "##vso[task.setvariable variable=imageQueueTime]$(date --rfc-2822)"
displayName: Set Publish Variables
- script: >
$(runImageBuilderCmd) trimUnchangedPlatforms
'$(imageInfoContainerDir)/image-info.json'
displayName: Trim Unchanged Images
- template: /eng/common/templates/steps/run-imagebuilder.yml@self
parameters:
displayName: Copy Images
serviceConnections:
- name: acr
id: $(publish.serviceConnection.id)
tenantId: $(publish.serviceConnection.tenantId)
clientId: $(publish.serviceConnection.clientId)
internalProjectName: ${{ parameters.internalProjectName }}
args: >-
copyAcrImages
'$(acr.subscription)'
'$(acr.resourceGroup)'
'$(stagingRepoPrefix)'
'$(acr-staging.server)'
--os-type '*'
--architecture '*'
--repo-prefix '$(publishRepoPrefix)'
--image-info '$(imageInfoContainerDir)/image-info.json'
$(dryRunArg)
$(imageBuilder.pathArgs)
$(imageBuilder.commonCmdArgs)
- template: /eng/common/templates/steps/run-imagebuilder.yml@self
parameters:
displayName: Publish Manifest
serviceConnections:
- name: acr
id: $(publish.serviceConnection.id)
tenantId: $(publish.serviceConnection.tenantId)
clientId: $(publish.serviceConnection.clientId)
internalProjectName: ${{ parameters.internalProjectName }}
dockerClientOS: ${{ parameters.dockerClientOS }}
args: >-
publishManifest
'$(imageInfoContainerDir)/image-info.json'
--repo-prefix '$(publishRepoPrefix)'
--os-type '*'
--architecture '*'
$(dryRunArg)
$(imageBuilder.pathArgs)
$(imageBuilder.commonCmdArgs)
- template: /eng/common/templates/steps/publish-artifact.yml@self
parameters:
path: $(imageInfoHostDir)
artifactName: image-info-final-$(System.JobAttempt)
displayName: Publish Image Info File Artifact
internalProjectName: ${{ parameters.internalProjectName }}
publicProjectName: ${{ parameters.publicProjectName }}
- template: /eng/common/templates/steps/wait-for-mcr-image-ingestion.yml@self
parameters:
imageInfoPath: '$(imageinfoContainerDir)/image-info.json'
minQueueTime: $(imageQueueTime)
dryRunArg: $(dryRunArg)
condition: succeeded()
- template: /eng/common/templates/steps/publish-readmes.yml@self
parameters:
dryRunArg: $(dryRunArg)
condition: and(succeeded(), eq(variables['publishReadme'], 'true'))
- script: mkdir -p $(Build.ArtifactStagingDirectory)/eol-annotation-data
displayName: Create EOL Annotation Data Directory
- script: >
curl -fSL
--output $(imageInfoHostDir)/full-image-info-orig.json
https://raw.githubusercontent.com/$(gitHubVersionsRepoInfo.org)/$(gitHubVersionsRepoInfo.repo)/refs/heads/$(gitHubVersionsRepoInfo.branch)/$(gitHubImageInfoVersionsPath)
condition: and(succeeded(), eq(variables['publishImageInfo'], 'true'))
displayName: Download Latest Image Info
- script: >
$(runImageBuilderCmd) mergeImageInfo
$(imageInfoContainerDir)
$(imageInfoContainerDir)/full-image-info-new.json
$(manifestVariables)
$(dryRunArg)
--manifest $(manifest)
--publish
--initial-image-info-path $(imageInfoContainerDir)/full-image-info-orig.json
condition: and(succeeded(), eq(variables['publishImageInfo'], 'true'))
displayName: Merge Image Info
- template: /eng/common/templates/steps/run-imagebuilder.yml@self
parameters:
displayName: Ingest Kusto Image Info
serviceConnections:
- name: kusto
id: $(kusto.serviceConnection.id)
tenantId: $(kusto.serviceConnection.tenantId)
clientId: $(kusto.serviceConnection.clientId)
internalProjectName: ${{ parameters.internalProjectName }}
condition: and(succeeded(), eq(variables['ingestKustoImageInfo'], 'true'))
args: >-
ingestKustoImageInfo
'$(imageInfoContainerDir)/image-info.json'
'$(kusto.cluster)'
'$(kusto.database)'
'$(kusto.imageTable)'
'$(kusto.layerTable)'
--os-type '*'
--architecture '*'
$(dryRunArg)
$(imageBuilder.commonCmdArgs)
- template: /eng/common/templates/steps/run-imagebuilder.yml@self
parameters:
displayName: Generate EOL Annotation Data
serviceConnections:
- name: acr
id: $(publish.serviceConnection.id)
tenantId: $(publish.serviceConnection.tenantId)
clientId: $(publish.serviceConnection.clientId)
internalProjectName: internal
condition: and(succeeded(), eq(variables['publishEolAnnotations'], 'true'))
args: >-
generateEolAnnotationData
'$(artifactsPath)/eol-annotation-data/eol-annotation-data.json'
'$(imageInfoContainerDir)/full-image-info-orig.json'
'$(imageInfoContainerDir)/full-image-info-new.json'
'$(acr.server)'
'$(publishRepoPrefix)'
$(generateEolAnnotationDataExtraOptions)
$(dryRunArg)
- template: /eng/common/templates/steps/publish-artifact.yml@self
parameters:
path: $(Build.ArtifactStagingDirectory)/eol-annotation-data
artifactName: eol-annotation-data-$(System.JobAttempt)
displayName: Publish EOL Annotation Data Artifact
internalProjectName: internal
publicProjectName: public
condition: and(succeeded(), eq(variables['publishEolAnnotations'], 'true'))
- template: /eng/common/templates/steps/annotate-eol-digests.yml@self
parameters:
internalProjectName: ${{ parameters.internalProjectName }}
dataFile: $(artifactsPath)/eol-annotation-data/eol-annotation-data.json
- script: >
$(runImageBuilderCmd) publishImageInfo
'$(imageInfoContainerDir)/full-image-info-new.json'
'$(gitHubVersionsRepoInfo.userName)'
'$(gitHubVersionsRepoInfo.email)'
$(gitHubVersionsRepoInfo.authArgs)
--git-owner '$(gitHubVersionsRepoInfo.org)'
--git-repo '$(gitHubVersionsRepoInfo.repo)'
--git-branch '$(gitHubVersionsRepoInfo.branch)'
--git-path '$(gitHubImageInfoVersionsPath)'
$(dryRunArg)
$(imageBuilder.commonCmdArgs)
condition: and(succeeded(), eq(variables['publishImageInfo'], 'true'))
displayName: Publish Image Info
# Task displayNames names are hardcoded to reference the task prefix used by 1ES official
# pipelines in eng/common/templates/1es-official.yml.
#
# These will fail if they are dependend on by an unofficial pipeline since they use a unique task
# prefix compared to official pipelines (see eng/common/templates/1es-unofficial.yml). This is
# acceptable because unofficial pipelines should not publish images.
#
# https://github.com/dotnet/docker-tools/issues/1698 tracks making this command no longer depend
# on individual step displayNames.
- script: >
$(runImageBuilderCmd) postPublishNotification
'$(publishNotificationRepoName)'
'$(branchName)'
'$(imageInfoContainerDir)/image-info.json'
$(Build.BuildId)
'$(System.AccessToken)'
'$(azdoOrgName)'
'$(System.TeamProject)'
$(gitHubNotificationsRepoInfo.authArgs)
'$(gitHubNotificationsRepoInfo.org)'
'$(gitHubNotificationsRepoInfo.repo)'
--repo-prefix '$(publishRepoPrefix)'
--task "🟪 Copy Images"
--task "🟪 Publish Manifest"
--task "🟪 Wait for Image Ingestion"
--task "🟪 Publish Readmes"
--task "🟪 Wait for MCR Doc Ingestion"
--task "🟪 Publish Image Info"
--task "🟪 Ingest Kusto Image Info"
--task "🟪 Generate EOL Annotation Data"
--task "🟪 Annotate EOL Images"
--task "🟪 Wait for Annotation Ingestion"
$(dryRunArg)
$(imageBuilder.commonCmdArgs)
displayName: Post Publish Notification
condition: and(always(), eq(variables['publishNotificationsEnabled'], 'true'))
- powershell: |
# Default to current build number if parameter was not overridden
$buildId = "${{ parameters.sourceBuildPipelineRunId }}"
if ($buildId -eq "") {
$buildId = "$(Build.BuildNumber)"
}
New-Item -ItemType Directory -Path $(sourceBuildIdOutputDir)
Set-Content -Path $(sourceBuildIdOutputDir)/source-build-id.txt -Value "$buildId"
condition: succeeded()
displayName: Write Source Build ID to File
- template: /eng/common/templates/steps/publish-artifact.yml@self
parameters:
path: $(sourceBuildIdOutputDir)
artifactName: source-build-id
displayName: Publish Source Build ID Artifact
internalProjectName: ${{ parameters.internalProjectName }}
publicProjectName: ${{ parameters.publicProjectName }}