Skip to content

Commit 3863d65

Browse files
author
Evans Aboge (from Dev Box)
committed
Update pipeline
1 parent c10aa97 commit 3863d65

File tree

1 file changed

+39
-14
lines changed

1 file changed

+39
-14
lines changed

.azure-pipelines/ci-build.yml

Lines changed: 39 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,24 @@ trigger:
66
branches:
77
include:
88
- main
9-
- dev
10-
- support/v1
11-
- task/migrate-acr-pipeline
129
paths:
1310
include:
14-
- src/Microsoft.OpenApi.Hidi/**
11+
- src/**
1512
- .azure-pipelines/**
13+
tags:
14+
include:
15+
- v*
16+
17+
pr:
18+
branches:
19+
include:
20+
- main
21+
- task/migrate-acr-pipeline
1622

1723
variables:
1824
REGISTRY: 'msgraphpperegistry.azurecr.io'
1925
IMAGE_NAME: 'public/openapi/hidi'
20-
DEV_BRANCH: 'refs/heads/dev'
21-
MAIN_BRANCH: 'refs/heads/task/migrate-acr-pipeline'
22-
SUPPORT_BRANCH: 'refs/heads/support/v1'
26+
PREVIEW_BRANCH: 'refs/heads/task/migrate-acr-pipeline'
2327

2428
pool:
2529
vmImage: 'ubuntu-latest'
@@ -30,35 +34,56 @@ steps:
3034
- task: AzureCLI@2
3135
displayName: 'Login to Azure Container Registry'
3236
inputs:
33-
azureSubscription: 'ACR Push Test'
37+
azureSubscription: 'ACR Push Test' # Use your service connection name here
3438
scriptType: bash
3539
scriptLocation: inlineScript
3640
inlineScript: |
37-
az acr login --name $(REGISTRY)
41+
az acr login --name $(REGISTRY:$(REGISTRY).azurecr.io)
3842
3943
- powershell: |
4044
$content = [XML](Get-Content ./src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj)
4145
$version = $content.Project.PropertyGroup.Version
4246
Write-Host "Version found: $version"
4347
Write-Host "##vso[task.setvariable variable=version]$version"
4448
displayName: 'Get version from csproj'
49+
name: getversion
50+
51+
- bash: |
52+
runnumber=$(echo $(Build.BuildNumber) | awk '{ print substr($0, length($0)-3, length($0)) }')
53+
echo "##vso[task.setvariable variable=runnumber]$runnumber"
54+
displayName: 'Get truncated run number'
55+
condition: eq(variables['Build.SourceBranch'], variables['PREVIEW_BRANCH'])
56+
57+
- bash: |
58+
date=$(date +'%Y%m%d')
59+
echo "##vso[task.setvariable variable=date]$date"
60+
displayName: 'Get current date'
61+
condition: eq(variables['Build.SourceBranch'], variables['PREVIEW_BRANCH'])
4562
4663
- bash: |
4764
echo "Building Docker image..."
48-
docker build -t $(REGISTRY)/$(IMAGE_NAME):nightly "$(Build.SourcesDirectory)"
65+
docker build \
66+
--build-arg version_suffix=preview.$(date)$(runnumber) \
67+
-t $(REGISTRY)/$(IMAGE_NAME):nightly \
68+
-t $(REGISTRY)/$(IMAGE_NAME):$(version)-preview.$(date)$(runnumber) \
69+
"$(Build.SourcesDirectory)"
4970
5071
echo "Pushing Docker image with nightly tag..."
5172
docker push $(REGISTRY)/$(IMAGE_NAME):nightly
73+
docker push $(REGISTRY)/$(IMAGE_NAME):$(version)-preview.$(date)$(runnumber)
5274
displayName: 'Build and Push Nightly Image'
53-
condition: eq(variables['Build.SourceBranch'], variables['DEV_BRANCH'])
75+
condition: eq(variables['Build.SourceBranch'], variables['PREVIEW_BRANCH'])
5476
5577
- bash: |
56-
echo "Building Docker image..."
57-
docker build -t $(REGISTRY)/$(IMAGE_NAME):latest -t $(REGISTRY)/$(IMAGE_NAME):$(version) "$(Build.SourcesDirectory)"
78+
echo "Building Docker image for release..."
79+
docker build \
80+
-t $(REGISTRY)/$(IMAGE_NAME):latest \
81+
-t $(REGISTRY)/$(IMAGE_NAME):$(version) \
82+
"$(Build.SourcesDirectory)"
5883
5984
echo "Pushing Docker image with latest and version tags..."
6085
docker push $(REGISTRY)/$(IMAGE_NAME):latest
6186
docker push $(REGISTRY)/$(IMAGE_NAME):$(version)
6287
displayName: 'Build and Push Release Image'
63-
condition: or(eq(variables['Build.SourceBranch'], variables['MAIN_BRANCH']), eq(variables['Build.SourceBranch'], variables['SUPPORT_BRANCH']))
88+
condition: startsWith(variables['Build.SourceBranch'], 'refs/tags/v')
6489

0 commit comments

Comments
 (0)