Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 41 additions & 43 deletions .pipelines/templates/.builder-release-template-windows.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -220,48 +220,10 @@ steps:
SIG_GALLERY_NAME: $(SIG_GALLERY_NAME)
SIG_IMAGE_VERSION: $(SIG_IMAGE_VERSION)

# SA_NAME: Temporary storage account name
# IMPORTED_IMAGE_NAME: Build output for windowsVhdMode is SIG. Packer does not support building a SIG from raw
# VHD blob directly. Will use this as an intermediate sig to import from raw VHD url.
# Can be deleted after building.
# SIG_IMAGE_NAME: Packer-generated SIG image for windowsVhdMode. (Gen 2 included) If SIG_FOR_PRODUCTION = True
# This image should be deleted. Otherwise, we keep it.
# Used to define the IMAGE_NAME below.
# IMAGE_NAME: Managed image created by packer: ManagedImageName in log. No longer used.
# Can be cleaned up in this step.
- task: AzureCLI@2
inputs:
azureSubscription: $(VHD_ARM_SERVICE_CONNECTION)
scriptType: bash
scriptLocation: inlineScript
inlineScript: |
set -e

export PKR_RG_NAME="$(cat packer-output | grep -a "ResourceGroupName" | cut -d "'" -f 2 | head -1)"
export SA_NAME="$(cat packer-output | grep -a "storage name:" | cut -d " " -f 3)"
export IMPORTED_IMAGE_NAME="$(cat vhdbuilder/packer/settings.json | grep "imported_image_name" | awk -F':' '{print $2}' | awk -F'"' '{print $2}')"
export SIG_IMAGE_NAME="$(cat vhdbuilder/packer/settings.json | grep "sig_image_name" | awk -F':' '{print $2}' | awk -F'"' '{print $2}')"
export IMAGE_NAME="$(cat packer-output | grep -a "ManagedImageName:" | cut -d " " -f 2)"

./vhdbuilder/packer/cleanup.sh
displayName: Clean Up Packer Generated Resources
condition: always()
env:
MODE: $(MODE)
DRY_RUN: $( DRY_RUN )
VNET_RESOURCE_GROUP_NAME: $(VNET_RESOURCE_GROUP_NAME)
TEST_VM_RESOURCE_GROUP_NAME: $(TEST_VM_RESOURCE_GROUP_NAME)
SKIP_EXTENSION_CHECK: ${{ parameters.skipExtensionCheck }}
WINDOWS_SKU: ${{ parameters.windowsSku }}
SIG_GALLERY_NAME: $(SIG_GALLERY_NAME)
SIG_IMAGE_VERSION: $(SIG_IMAGE_VERSION)
SIG_FOR_PRODUCTION: $(SIG_FOR_PRODUCTION)
OS_TYPE: "Windows"

# Set VHD_NAME and SKU_NAME which will be published.
# Note: use -a to grep OS_DISK_SAS (packer-output should be read as a binary file in Linux)
# Perform this step only if we want to publish the VHD: Gen 1 or Gen 2 and the built sig is for production.
- task: AzureCLI@2
# we always generate these artifacts - sometimes they are used by downstream pipelines even when
# we are not publishing the image to production.
inputs:
azureSubscription: $(VHD_ARM_SERVICE_CONNECTION)
scriptType: bash
Expand All @@ -280,7 +242,6 @@ steps:

make -f packer.mk generate-publishing-info
displayName: Getting Shared Access Signature URI
condition: and(succeeded(), eq(variables.DRY_RUN, 'False'), eq(variables.SIG_FOR_PRODUCTION, 'True'))
env:
SUBSCRIPTION_ID: $(AZURE_PROD_SUBSCRIPTION_ID)
STORAGE_ACCT_BLOB_URL: $(STORAGE_ACCT_BLOB_URL)
Comment thread
timmy-wright marked this conversation as resolved.
Expand All @@ -295,9 +256,46 @@ steps:
OS_TYPE: "Windows"
WINDOWS_SKU: ${{ parameters.windowsSku }}

# Will be stepped in if the sig is for production
- task: PublishPipelineArtifact@1
inputs:
artifactName: 'publishing-info-${{ parameters.artifactName }}'
targetPath: 'vhd-publishing-info.json'
condition: and(succeeded(), eq(variables.DRY_RUN, 'False'), eq(variables.SIG_FOR_PRODUCTION, 'True'))


# SA_NAME: Temporary storage account name
# IMPORTED_IMAGE_NAME: Build output for windowsVhdMode is SIG. Packer does not support building a SIG from raw
# VHD blob directly. Will use this as an intermediate sig to import from raw VHD url.
# Can be deleted after building.
# SIG_IMAGE_NAME: Packer-generated SIG image for windowsVhdMode. (Gen 2 included) If SIG_FOR_PRODUCTION = True
# This image should be deleted. Otherwise, we keep it.
# Used to define the IMAGE_NAME below.
# IMAGE_NAME: Managed image created by packer: ManagedImageName in log. No longer used.
# Can be cleaned up in this step.
- task: AzureCLI@2
inputs:
azureSubscription: $(VHD_ARM_SERVICE_CONNECTION)
scriptType: bash
scriptLocation: inlineScript
inlineScript: |
set -e

export PKR_RG_NAME="$(cat packer-output | grep -a "ResourceGroupName" | cut -d "'" -f 2 | head -1)"
export SA_NAME="$(cat packer-output | grep -a "storage name:" | cut -d " " -f 3)"
export IMPORTED_IMAGE_NAME="$(cat vhdbuilder/packer/settings.json | grep "imported_image_name" | awk -F':' '{print $2}' | awk -F'"' '{print $2}')"
export SIG_IMAGE_NAME="$(cat vhdbuilder/packer/settings.json | grep "sig_image_name" | awk -F':' '{print $2}' | awk -F'"' '{print $2}')"
export IMAGE_NAME="$(cat packer-output | grep -a "ManagedImageName:" | cut -d " " -f 2)"

./vhdbuilder/packer/cleanup.sh
displayName: Clean Up Packer Generated Resources
condition: always()
env:
MODE: $(MODE)
DRY_RUN: $( DRY_RUN )
VNET_RESOURCE_GROUP_NAME: $(VNET_RESOURCE_GROUP_NAME)
TEST_VM_RESOURCE_GROUP_NAME: $(TEST_VM_RESOURCE_GROUP_NAME)
SKIP_EXTENSION_CHECK: ${{ parameters.skipExtensionCheck }}
WINDOWS_SKU: ${{ parameters.windowsSku }}
SIG_GALLERY_NAME: $(SIG_GALLERY_NAME)
SIG_IMAGE_VERSION: $(SIG_IMAGE_VERSION)
SIG_FOR_PRODUCTION: $(SIG_FOR_PRODUCTION)
OS_TYPE: "Windows"
Loading