Skip to content

Commit af15217

Browse files
author
Evans Aboge (from Dev Box)
committed
Fix indentation
1 parent 2b391c2 commit af15217

File tree

1 file changed

+108
-109
lines changed

1 file changed

+108
-109
lines changed

.azure-pipelines/ci-build.yml

Lines changed: 108 additions & 109 deletions
Original file line numberDiff line numberDiff line change
@@ -319,118 +319,117 @@ extends:
319319
assets: '$(Pipeline.Workspace)\**\*.exe'
320320
addChangeLog: false
321321

322-
- stage: Build and deploy docker images
322+
- stage: Build_and_deploy_docker_images
323+
displayName: 'Build and deploy docker images'
323324
condition: and(or(contains(variables['build.sourceBranch'], 'refs/tags/v'), eq(variables['build.sourceBranch'], variables['PREVIEW_BRANCH'])), succeeded())
324325
dependsOn: build
325326
jobs:
326-
- buildAndPush:
327-
pool:
328-
vmImage: 'ubuntu-latest'
329-
steps:
330-
- task: AzureCLI@2
331-
displayName: 'Login to Azure Container Registry'
332-
inputs:
333-
azureSubscription: 'ACR Images Push Service Connection'
334-
scriptType: bash
335-
scriptLocation: inlineScript
336-
inlineScript: |
337-
az acr login --name msgraphprodregistry
338-
339-
- powershell: |
340-
$content = [XML](Get-Content ./Directory.Build.props)
341-
Write-Host "XML loaded, finding version..."
342-
343-
# Handle PropertyGroup as either a single element or array
344-
$version = $null
345-
if ($content.Project.PropertyGroup -is [array]) {
346-
Write-Host "PropertyGroup is an array, checking each entry..."
347-
foreach ($pg in $content.Project.PropertyGroup) {
348-
if ($pg.Version) {
349-
$version = $pg.Version.ToString().Trim()
350-
Write-Host "Found version in PropertyGroup array: $version"
351-
break
352-
}
353-
}
354-
} else {
355-
# Single PropertyGroup
356-
$version = $content.Project.PropertyGroup.Version
357-
if ($version) {
358-
$version = $version.ToString().Trim()
359-
Write-Host "Found version in PropertyGroup: $version"
327+
- job: buildAndPush
328+
pool:
329+
vmImage: 'ubuntu-latest'
330+
steps:
331+
- task: AzureCLI@2
332+
displayName: 'Login to Azure Container Registry'
333+
inputs:
334+
azureSubscription: 'ACR Images Push Service Connection'
335+
scriptType: bash
336+
scriptLocation: inlineScript
337+
inlineScript: |
338+
az acr login --name msgraphprodregistry
339+
340+
- powershell: |
341+
$content = [XML](Get-Content ./Directory.Build.props)
342+
Write-Host "XML loaded, finding version..."
343+
344+
# Handle PropertyGroup as either a single element or array
345+
$version = $null
346+
if ($content.Project.PropertyGroup -is [array]) {
347+
Write-Host "PropertyGroup is an array, checking each entry..."
348+
foreach ($pg in $content.Project.PropertyGroup) {
349+
if ($pg.Version) {
350+
$version = $pg.Version.ToString().Trim()
351+
Write-Host "Found version in PropertyGroup array: $version"
352+
break
360353
}
361354
}
362-
363-
if (-not $version) {
364-
Write-Host "##vso[task.logissue type=error]Version not found in Directory.Build.props"
365-
exit 1
355+
} else {
356+
# Single PropertyGroup
357+
$version = $content.Project.PropertyGroup.Version
358+
if ($version) {
359+
$version = $version.ToString().Trim()
360+
Write-Host "Found version in PropertyGroup: $version"
366361
}
367-
368-
Write-Host "Version found: $version"
369-
Write-Host "##vso[task.setvariable variable=version;isoutput=true]$version"
370-
Write-Host "##vso[task.setvariable variable=VERSION]$version"
371-
displayName: 'Get version from csproj'
372-
name: getversion
373-
374-
- bash: |
375-
# Debug output to verify version variable
376-
echo "Version from previous step: $VERSION"
377-
displayName: 'Verify version variable'
378-
379-
- bash: |
380-
echo "Build Number: $(Build.BuildNumber)"
381-
# Extract the last 3 characters for the run number
382-
runnumber=$(echo "$(Build.BuildNumber)" | grep -o '[0-9]\+$')
383-
echo "Extracted Run Number: $runnumber"
384-
385-
# If extraction fails, set a default
386-
if [ -z "$runnumber" ]; then
387-
echo "Extraction failed, using default value"
388-
runnumber=$(date +"%S%N" | cut -c1-3)
389-
echo "Generated fallback run number: $runnumber"
390-
fi
391-
392-
# Set the variable for later steps
393-
echo "##vso[task.setvariable variable=RUNNUMBER]$runnumber"
394-
echo "##vso[task.setvariable variable=RUNNUMBER;isOutput=true]$runnumber"
395-
displayName: 'Get truncated run number'
396-
name: getrunnumber
397-
condition: eq(variables['Build.SourceBranch'], variables['PREVIEW_BRANCH'])
398-
399-
- bash: |
400-
date=$(date +'%Y%m%d')
401-
echo "Date value: $date"
402-
echo "##vso[task.setvariable variable=BUILDDATE;isOutput=true]$date"
403-
echo "##vso[task.setvariable variable=BUILDDATE]$date"
404-
displayName: 'Get current date'
405-
name: setdate
406-
condition: eq(variables['Build.SourceBranch'], variables['PREVIEW_BRANCH'])
407-
408-
- bash: |
409-
echo "Building Docker image..."
410-
echo "Using build date: ${BUILDDATE}"
411-
# Using quotes around tags to prevent flag interpretation
412-
docker build \
413-
-t "$(REGISTRY)/$(IMAGE_NAME):nightly" \
414-
-t "$(REGISTRY)/$(IMAGE_NAME):${VERSION}.${BUILDDATE}${RUNNUMBER}" \
415-
"$(Build.SourcesDirectory)"
416-
417-
echo "Pushing Docker image with nightly tag..."
418-
docker push "$(REGISTRY)/$(IMAGE_NAME):nightly"
419-
docker push "$(REGISTRY)/$(IMAGE_NAME):${VERSION}.${BUILDDATE}${RUNNUMBER}"
420-
displayName: 'Build and Push Nightly Image'
421-
condition: eq(variables['Build.SourceBranch'], variables['PREVIEW_BRANCH'])
422-
423-
- bash: |
424-
echo "Building Docker image for release..."
425-
docker build \
426-
-t "$(REGISTRY)/$(IMAGE_NAME):latest" \
427-
-t "$(REGISTRY)/$(IMAGE_NAME):${VERSION}.${BUILDDATE}${RUNNUMBER}" \
428-
"$(Build.SourcesDirectory)"
429-
430-
echo "Pushing Docker image with latest and version tags..."
431-
docker push "$(REGISTRY)/$(IMAGE_NAME):latest"
432-
docker push "$(REGISTRY)/$(IMAGE_NAME):${VERSION}.${BUILDDATE}${RUNNUMBER}"
433-
displayName: 'Build and Push Release Image'
434-
condition: startsWith(variables['Build.SourceBranch'], 'refs/tags/v')
435-
436-
362+
}
363+
364+
if (-not $version) {
365+
Write-Host "##vso[task.logissue type=error]Version not found in Directory.Build.props"
366+
exit 1
367+
}
368+
369+
Write-Host "Version found: $version"
370+
Write-Host "##vso[task.setvariable variable=version;isoutput=true]$version"
371+
Write-Host "##vso[task.setvariable variable=VERSION]$version"
372+
displayName: 'Get version from csproj'
373+
name: getversion
374+
375+
- bash: |
376+
# Debug output to verify version variable
377+
echo "Version from previous step: $VERSION"
378+
displayName: 'Verify version variable'
379+
380+
- bash: |
381+
echo "Build Number: $(Build.BuildNumber)"
382+
# Extract the last 3 characters for the run number
383+
runnumber=$(echo "$(Build.BuildNumber)" | grep -o '[0-9]\+$')
384+
echo "Extracted Run Number: $runnumber"
385+
386+
# If extraction fails, set a default
387+
if [ -z "$runnumber" ]; then
388+
echo "Extraction failed, using default value"
389+
runnumber=$(date +"%S%N" | cut -c1-3)
390+
echo "Generated fallback run number: $runnumber"
391+
fi
392+
393+
# Set the variable for later steps
394+
echo "##vso[task.setvariable variable=RUNNUMBER]$runnumber"
395+
echo "##vso[task.setvariable variable=RUNNUMBER;isOutput=true]$runnumber"
396+
displayName: 'Get truncated run number'
397+
name: getrunnumber
398+
condition: eq(variables['Build.SourceBranch'], variables['PREVIEW_BRANCH'])
399+
400+
- bash: |
401+
date=$(date +'%Y%m%d')
402+
echo "Date value: $date"
403+
echo "##vso[task.setvariable variable=BUILDDATE;isOutput=true]$date"
404+
echo "##vso[task.setvariable variable=BUILDDATE]$date"
405+
displayName: 'Get current date'
406+
name: setdate
407+
condition: eq(variables['Build.SourceBranch'], variables['PREVIEW_BRANCH'])
408+
409+
- bash: |
410+
echo "Building Docker image..."
411+
echo "Using build date: ${BUILDDATE}"
412+
# Using quotes around tags to prevent flag interpretation
413+
docker build \
414+
-t "$(REGISTRY)/$(IMAGE_NAME):nightly" \
415+
-t "$(REGISTRY)/$(IMAGE_NAME):${VERSION}.${BUILDDATE}${RUNNUMBER}" \
416+
"$(Build.SourcesDirectory)"
417+
418+
echo "Pushing Docker image with nightly tag..."
419+
docker push "$(REGISTRY)/$(IMAGE_NAME):nightly"
420+
docker push "$(REGISTRY)/$(IMAGE_NAME):${VERSION}.${BUILDDATE}${RUNNUMBER}"
421+
displayName: 'Build and Push Nightly Image'
422+
condition: eq(variables['Build.SourceBranch'], variables['PREVIEW_BRANCH'])
423+
424+
- bash: |
425+
echo "Building Docker image for release..."
426+
docker build \
427+
-t "$(REGISTRY)/$(IMAGE_NAME):latest" \
428+
-t "$(REGISTRY)/$(IMAGE_NAME):${VERSION}.${BUILDDATE}${RUNNUMBER}" \
429+
"$(Build.SourcesDirectory)"
430+
431+
echo "Pushing Docker image with latest and version tags..."
432+
docker push "$(REGISTRY)/$(IMAGE_NAME):latest"
433+
docker push "$(REGISTRY)/$(IMAGE_NAME):${VERSION}.${BUILDDATE}${RUNNUMBER}"
434+
displayName: 'Build and Push Release Image'
435+
condition: startsWith(variables['Build.SourceBranch'], 'refs/tags/v')

0 commit comments

Comments
 (0)