@@ -49,6 +49,10 @@ extends:
49
49
displayName : ' Publish Artifact: Nugets'
50
50
artifactName : Nugets
51
51
targetPath : ' $(Build.ArtifactStagingDirectory)/Nugets'
52
+ - output : pipelineArtifact
53
+ displayName : ' Publish Artifact: RepoFiles'
54
+ artifactName : RepoFiles
55
+ targetPath : ' $(Build.ArtifactStagingDirectory)/RepoFiles'
52
56
steps :
53
57
- task : UseDotNet@2
54
58
displayName : ' Use .NET 6'
@@ -198,12 +202,29 @@ extends:
198
202
targetFolder : $(Build.ArtifactStagingDirectory)/Nugets
199
203
sourceFolder : $(Build.ArtifactStagingDirectory)
200
204
content : ' *.nupkg'
201
-
205
+
206
+ # Copy repository files to be used in the deploy stage
207
+ - task : CopyFiles@2
208
+ displayName : ' Copy repository files for deploy stage'
209
+ inputs :
210
+ SourceFolder : ' $(Build.SourcesDirectory)'
211
+ Contents : |
212
+ **/*
213
+ !**/bin/**
214
+ !**/obj/**
215
+ !**/.git/**
216
+ TargetFolder : ' $(Build.ArtifactStagingDirectory)/RepoFiles'
217
+
202
218
- stage : deploy
203
- condition : and(contains(variables['build.sourceBranch '], 'refs/tags/v'), succeeded())
219
+ condition : and(or( contains(variables['Build.SourceBranch '], 'refs/tags/v'), eq(variables['Build.SourceBranch'], variables['PREVIEW_BRANCH']) ), succeeded())
204
220
dependsOn : build
221
+ pool :
222
+ name : Azure-Pipelines-1ESPT-ExDShared
223
+ os : linux
224
+ image : ubuntu-latest
205
225
jobs :
206
226
- deployment : deploy_hidi
227
+ condition : and(contains(variables['build.SourceBranch'], 'refs/tags/v'), succeeded())
207
228
templateContext :
208
229
type : releaseJob
209
230
isProduction : true
@@ -228,6 +249,7 @@ extends:
228
249
publishFeedCredentials : ' OpenAPI Nuget Connection'
229
250
230
251
- deployment : deploy_lib
252
+ condition : and(contains(variables['build.SourceBranch'], 'refs/tags/v'), succeeded())
231
253
templateContext :
232
254
type : releaseJob
233
255
isProduction : true
@@ -260,6 +282,7 @@ extends:
260
282
publishFeedCredentials : ' OpenAPI Nuget Connection'
261
283
262
284
- deployment : deploy_yaml_reader
285
+ condition : and(contains(variables['build.SourceBranch'], 'refs/tags/v'), succeeded())
263
286
templateContext :
264
287
type : releaseJob
265
288
isProduction : true
@@ -318,119 +341,132 @@ extends:
318
341
assets : ' $(Pipeline.Workspace)\**\*.exe'
319
342
addChangeLog : false
320
343
321
- - stage : Build_and_deploy_docker_images
322
- displayName : ' Build and deploy docker images'
323
- condition : or(eq(variables['build.sourceBranch'], 'refs/tags/v'), eq(variables['build.sourceBranch'], variables['PREVIEW_BRANCH']))
324
- dependsOn : build
325
- pool :
326
- name : Azure-Pipelines-1ESPT-ExDShared
327
- image : ubuntu-latest
328
- os : linux
329
- jobs :
330
- - job : buildAndPush
331
- steps :
332
- - task : AzureCLI@2
333
- displayName : ' Login to Azure Container Registry'
334
- inputs :
335
- azureSubscription : ' ACR Images Push Service Connection'
336
- scriptType : bash
337
- scriptLocation : inlineScript
338
- inlineScript : |
339
- az acr login --name msgraphprodregistry
340
-
341
- - powershell : |
342
- $content = [XML](Get-Content ./Directory.Build.props)
343
- Write-Host "XML loaded, finding version..."
344
-
345
- # Handle PropertyGroup as either a single element or array
346
- $version = $null
347
- if ($content.Project.PropertyGroup -is [array]) {
348
- Write-Host "PropertyGroup is an array, checking each entry..."
349
- foreach ($pg in $content.Project.PropertyGroup) {
350
- if ($pg.Version) {
351
- $version = $pg.Version.ToString().Trim()
352
- Write-Host "Found version in PropertyGroup array: $version"
353
- break
344
+ - deployment : deploy_docker_image
345
+ environment : docker-images-deploy
346
+ templateContext :
347
+ type : releaseJob
348
+ isProduction : true
349
+ inputs :
350
+ - input : pipelineArtifact
351
+ artifactName : RepoFiles
352
+ targetPath : ' $(Pipeline.Workspace)'
353
+ strategy :
354
+ runOnce :
355
+ deploy :
356
+ pool :
357
+ vmImage : ' ubuntu-latest'
358
+ steps :
359
+ - task : AzureCLI@2
360
+ displayName : ' Login to Azure Container Registry'
361
+ inputs :
362
+ azureSubscription : ' ACR Images Push Service Connection'
363
+ scriptType : bash
364
+ scriptLocation : inlineScript
365
+ inlineScript : |
366
+ az acr login --name $(REGISTRY)
367
+
368
+ - powershell : |
369
+ $content = [XML](Get-Content $(Pipeline.Workspace)/Directory.Build.props)
370
+ Write-Host "XML loaded, finding version..."
371
+
372
+ # Handle PropertyGroup as either a single element or array
373
+ $version = $null
374
+ if ($content.Project.PropertyGroup -is [array]) {
375
+ Write-Host "PropertyGroup is an array, checking each entry..."
376
+ foreach ($pg in $content.Project.PropertyGroup) {
377
+ if ($pg.Version) {
378
+ $version = $pg.Version.ToString().Trim()
379
+ Write-Host "Found version in PropertyGroup array: $version"
380
+ break
381
+ }
382
+ }
383
+ } else {
384
+ # Single PropertyGroup
385
+ $version = $content.Project.PropertyGroup.Version
386
+ if ($version) {
387
+ $version = $version.ToString().Trim()
388
+ Write-Host "Found version in PropertyGroup: $version"
389
+ }
354
390
}
355
- }
356
- } else {
357
- # Single PropertyGroup
358
- $version = $content.Project.PropertyGroup.Version
359
- if ($version) {
360
- $version = $version.ToString().Trim()
361
- Write-Host "Found version in PropertyGroup: $version"
362
- }
363
- }
391
+
392
+ if (-not $version) {
393
+ Write-Host "##vso[task.logissue type=error]Version not found in Directory.Build.props"
394
+ exit 1
395
+ }
396
+
397
+ Write-Host "Version found: $version"
398
+ Write-Host "##vso[task.setvariable variable=version;isoutput=true]$version"
399
+ Write-Host "##vso[task.setvariable variable=VERSION]$version"
400
+ displayName: 'Get version from csproj'
401
+ name: getversion
364
402
365
- if (-not $version) {
366
- Write-Host "##vso[task.logissue type=error]Version not found in Directory.Build.props"
367
- exit 1
368
- }
403
+ - bash : |
404
+ # Debug output to verify version variable
405
+ echo "Version from previous step: $VERSION"
406
+ displayName: 'Verify version variable'
369
407
370
- Write-Host "Version found: $version"
371
- Write-Host "##vso[task.setvariable variable=version;isoutput=true]$version"
372
- Write-Host "##vso[task.setvariable variable=VERSION]$version"
373
- displayName: 'Get version from csproj'
374
- name: getversion
375
-
376
- - bash : |
377
- # Debug output to verify version variable
378
- echo "Version from previous step: $VERSION"
379
- displayName: 'Verify version variable'
380
-
381
- - bash : |
382
- echo "Build Number: $(Build.BuildNumber)"
383
- # Extract the last 3 characters for the run number
384
- runnumber=$(echo "$(Build.BuildNumber)" | grep -o '[0-9]\+$')
385
- echo "Extracted Run Number: $runnumber"
408
+ - bash : |
409
+ echo "Build Number: $(Build.BuildNumber)"
410
+ # Extract the last 3 characters for the run number
411
+ runnumber=$(echo "$(Build.BuildNumber)" | grep -o '[0-9]\+$')
412
+ echo "Extracted Run Number: $runnumber"
413
+
414
+ # If extraction fails, set a default
415
+ if [ -z "$runnumber" ]; then
416
+ echo "Extraction failed, using default value"
417
+ runnumber=$(date +"%S%N" | cut -c1-3)
418
+ echo "Generated fallback run number: $runnumber"
419
+ fi
420
+
421
+ # Set the variable for later steps
422
+ echo "##vso[task.setvariable variable=RUNNUMBER]$runnumber"
423
+ echo "##vso[task.setvariable variable=RUNNUMBER;isOutput=true]$runnumber"
424
+ displayName: 'Get truncated run number'
425
+ name: getrunnumber
426
+ condition: eq(variables['Build.SourceBranch'], variables['PREVIEW_BRANCH'])
427
+
428
+ - bash : |
429
+ date=$(date +'%Y%m%d')
430
+ echo "Date value: $date"
431
+ echo "##vso[task.setvariable variable=BUILDDATE;isOutput=true]$date"
432
+ echo "##vso[task.setvariable variable=BUILDDATE]$date"
433
+ displayName: 'Get current date'
434
+ name: setdate
435
+ condition: eq(variables['Build.SourceBranch'], variables['PREVIEW_BRANCH'])
386
436
387
- # If extraction fails, set a default
388
- if [ -z "$runnumber" ]; then
389
- echo "Extraction failed, using default value"
390
- runnumber=$(date +"%S%N" | cut -c1-3)
391
- echo "Generated fallback run number: $runnumber"
392
- fi
393
-
394
- # Set the variable for later steps
395
- echo "##vso[task.setvariable variable=RUNNUMBER]$runnumber"
396
- echo "##vso[task.setvariable variable=RUNNUMBER;isOutput=true]$runnumber"
397
- displayName: 'Get truncated run number'
398
- name: getrunnumber
399
- condition: eq(variables['Build.SourceBranch'], variables['PREVIEW_BRANCH'])
400
-
401
- - bash : |
402
- date=$(date +'%Y%m%d')
403
- echo "Date value: $date"
404
- echo "##vso[task.setvariable variable=BUILDDATE;isOutput=true]$date"
405
- echo "##vso[task.setvariable variable=BUILDDATE]$date"
406
- displayName: 'Get current date'
407
- name: setdate
408
- condition: eq(variables['Build.SourceBranch'], variables['PREVIEW_BRANCH'])
409
-
410
- - bash : |
411
- echo "Building Docker image..."
412
- echo "Using build date: ${BUILDDATE}"
413
- # Using quotes around tags to prevent flag interpretation
414
- docker build \
415
- -t "$(REGISTRY)/$(IMAGE_NAME):nightly" \
416
- -t "$(REGISTRY)/$(IMAGE_NAME):${VERSION}.${BUILDDATE}${RUNNUMBER}" \
417
- "$(Build.SourcesDirectory)"
437
+ - script : |
438
+ docker run --privileged --rm tonistiigi/binfmt --install all
439
+ displayName: "Enable multi-platform builds"
440
+
441
+ - script : |
442
+ docker buildx create --use --name mybuilder
443
+ displayName: "Set up Docker BuildX"
444
+
445
+ - script : |
446
+ docker buildx inspect --bootstrap
447
+ displayName: "Ensure BuildX is working"
418
448
419
- echo "Pushing Docker image with nightly tag..."
420
- docker push "$(REGISTRY)/$(IMAGE_NAME):nightly"
421
- docker push "$(REGISTRY)/$(IMAGE_NAME):${VERSION}.${BUILDDATE}${RUNNUMBER}"
422
- displayName: 'Build and Push Nightly Image'
423
- condition: eq(variables['Build.SourceBranch'], variables['PREVIEW_BRANCH'])
424
-
425
- - bash : |
426
- echo "Building Docker image for release..."
427
- docker build \
428
- -t "$(REGISTRY)/$(IMAGE_NAME):latest" \
429
- -t "$(REGISTRY)/$(IMAGE_NAME):${VERSION}.${BUILDDATE}${RUNNUMBER}" \
430
- "$(Build.SourcesDirectory)"
449
+ - bash : |
450
+ echo "Building Docker image..."
451
+ echo "Using build date: ${BUILDDATE}"
452
+ # Using quotes around tags to prevent flag interpretation
453
+ docker buildx build \
454
+ --platform linux/amd64,linux/arm64/v8 \
455
+ --push \
456
+ -t "$(REGISTRY)/$(IMAGE_NAME):nightly" \
457
+ -t "$(REGISTRY)/$(IMAGE_NAME):${VERSION}.${BUILDDATE}${RUNNUMBER}" \
458
+ "$(Pipeline.Workspace)"
459
+
460
+ displayName: 'Build and Push Nightly Image'
461
+ condition: eq(variables['Build.SourceBranch'], variables['PREVIEW_BRANCH'])
431
462
432
- echo "Pushing Docker image with latest and version tags..."
433
- docker push "$(REGISTRY)/$(IMAGE_NAME):latest"
434
- docker push "$(REGISTRY)/$(IMAGE_NAME):${VERSION}.${BUILDDATE}${RUNNUMBER}"
435
- displayName: 'Build and Push Release Image'
436
- condition: startsWith(variables['Build.SourceBranch'], 'refs/tags/v')
463
+ - bash : |
464
+ echo "Building Docker image for release..."
465
+ docker buildx build\
466
+ --platform linux/amd64,linux/arm64/v8 \
467
+ --push \
468
+ -t "$(REGISTRY)/$(IMAGE_NAME):latest" \
469
+ -t "$(REGISTRY)/$(IMAGE_NAME):${VERSION}.${BUILDDATE}${RUNNUMBER}" \
470
+ "$(Pipeline.Workspace)"
471
+ displayName: 'Build and Push Release Image'
472
+ condition: contains(variables['Build.SourceBranch'], 'refs/tags/v')
0 commit comments