Add PR-specific tagging to pipeline ACR image push

Add PR-specific tagging to pipeline ACR image push

Update ACR push template to use dynamic PR-specific and build-specific tagging with TAG variable

Update ACR push template to use dynamic PR-specific and build-specific tagging with TAG variable

Update ACR push template to use dynamic PR-specific and build-specific tagging with TAG variable

Update ACR push template to use dynamic PR-specific and build-specific tagging with TAG variable

Update ACR push template to use dynamic PR-specific and build-specific tagging with TAG variable

Update ACR push template to use dynamic PR-specific and build-specific tagging with TAG variable

Update ACR push template to use dynamic PR-specific and build-specific tagging with TAG variable

Update ACR push template to use dynamic PR-specific and build-specific tagging with TAG variable

Update ACR push template to use dynamic PR-specific and build-specific tagging with TAG variable

Update ACR push template to use dynamic PR-specific and build-specific tagging with TAG variable
This commit is contained in:
Shubhada 2024-11-14 13:35:52 -08:00
Родитель 3189f829bf
Коммит a4d5d60ffa
2 изменённых файлов: 35 добавлений и 10 удалений

Просмотреть файл

@ -11,6 +11,11 @@ trigger:
include:
- v2*
pr:
branches:
include:
- '*'
variables:
- template: vars.yml
- name: CI
@ -25,8 +30,6 @@ variables:
value: arosvcdev.azurecr.io/vpn
- name: LOCAL_E2E_IMAGE
value: arosvcdev.azurecr.io/e2e
- name: TAG
value: $(Build.BuildId)
- name: VERSION
value: $(Build.BuildId)
- name: ARO_IMAGE
@ -39,7 +42,28 @@ variables:
value: aks.kubeconfig
stages:
- stage: Set_Tag_Variable
jobs:
- job: Set_Tag
pool:
name: 1es-aro-ci-pool
steps:
- script: |
echo "Build Reason: $(Build.Reason)"
echo "Pull Request ID: ${{ variables['System.PullRequest.PullRequestId'] }}"
if [ "$(Build.Reason)" == "PullRequest" ]; then
TAG="pr-${{ variables['System.PullRequest.PullRequestId'] }}"
else
TAG="$(Build.BuildId)"
fi
echo "Setting TAG to $TAG"
echo "##vso[task.setvariable variable=TAG;isOutput=true]$TAG"
displayName: "Set TAG Variable Globally"
- stage: Containerized_CI
dependsOn: Set_Tag_Variable
variables:
TAG: $[ dependencies.Set_Tag_Variable.outputs['Set_Tag.TAG'] ]
jobs:
- job: Build_Test_And_Push_Az_ARO_Extension
pool:
@ -50,7 +74,7 @@ stages:
# Build and test the Az ARO Extension
- script: |
set -xe
DOCKER_BUILD_CI_ARGS="--load" make ci-azext-aro VERSION=$(VERSION)
DOCKER_BUILD_CI_ARGS="--load" make ci-azext-aro VERSION=${TAG:-latest}
displayName: 🛠 Build & Test Az ARO Extension
# Push the image to ACR
@ -69,7 +93,7 @@ stages:
# Build and test RP and Portal
- script: |
set -xe
DOCKER_BUILD_CI_ARGS="--load" make ci-rp VERSION=$(VERSION)
DOCKER_BUILD_CI_ARGS="--load" make ci-rp VERSION=${TAG:-latest}
displayName: 🛠 Build & Test RP and Portal
# Publish test results
@ -104,7 +128,7 @@ stages:
# Build the E2E image
- script: |
set -xe
DOCKER_BUILD_CI_ARGS="--load" make aro-e2e VERSION=$(VERSION)
DOCKER_BUILD_CI_ARGS="--load" make aro-e2e VERSION=${TAG:-latest}
displayName: 🛠 Build the E2E image
# Push the E2E image to ACR

Просмотреть файл

@ -48,9 +48,10 @@ steps:
echo "Listing Docker images..."
docker images
# Define both the full repository image name and the local name
IMAGE_NAME="${ACR_FQDN}/${{ parameters.repository }}:$(VERSION)"
LOCAL_IMAGE="${{ parameters.repository }}:$(VERSION)"
# Define both the full repository image name and the local name, with a fallback for TAG if empty
TAG="${TAG:-latest}"
IMAGE_NAME="${ACR_FQDN}/${{ parameters.repository }}:$TAG"
LOCAL_IMAGE="${{ parameters.repository }}:$TAG"
# Check if the image exists locally with the full repository tag
echo "Checking for image $IMAGE_NAME..."
@ -80,8 +81,8 @@ steps:
SKIP_LATEST=false
fi
# Push the Docker image to ACR with the build ID
echo "Pushing image with build ID to ACR..."
# Push the Docker image to ACR with the TAG
echo "Pushing image with TAG to ACR..."
docker push $IMAGE_NAME
# Optionally push the image as 'latest'