Skip to content

Commit

Permalink
chore: skip VHD scanning during official builds (Azure#4865)
Browse files Browse the repository at this point in the history
Co-authored-by: Cameron Meissner <[email protected]>
  • Loading branch information
cameronmeissner and Cameron Meissner authored Aug 26, 2024
1 parent 033d5c9 commit 9fc9126
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
1 change: 1 addition & 0 deletions .pipelines/templates/.builder-release-template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ steps:
-e AZURE_RESOURCE_GROUP_NAME=${AZURE_RESOURCE_GROUP_NAME} \
-e BLOB_STORAGE_NAME=${BLOB_STORAGE_NAME} \
-e CLASSIC_BLOB=${CLASSIC_BLOB} \
-e ENVIRONMENT=${ENVIRONMENT} \
-e BUILD_ID=$(Build.BuildId) \
-e MANAGED_SIG_ID=${MANAGED_SIG_ID} \
-e PACKER_BUILD_LOCATION=${PACKER_BUILD_LOCATION} \
Expand Down
16 changes: 11 additions & 5 deletions vhdbuilder/packer/test-scan-and-cleanup.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/bin/bash

# TODO: assert required variables are set

retrycmd_if_failure() {
RETRIES=${1}; WAIT_SLEEP=${2}; CMD=${3}; TARGET=$(basename ${3} .sh)
echo "##[group]$TARGET" >> ${TARGET}-output.txt
Expand All @@ -24,7 +26,8 @@ if [[ -z "$SIG_GALLERY_NAME" ]]; then
SIG_GALLERY_NAME="PackerSigGalleryEastUS"
fi

SCRIPT_ARRAY+=("./vhdbuilder/packer/cleanup.sh") # Always run cleanup
# Always run cleanup
SCRIPT_ARRAY+=("./vhdbuilder/packer/cleanup.sh")

# Check to ensure the build step succeeded
SIG_VERSION=$(az sig image-version show \
Expand All @@ -40,20 +43,23 @@ if [ -z "${SIG_VERSION}" ]; then
exit $?
fi

# Setup tests
if [ "$IMG_SKU" != "20_04-lts-cvm" ]; then
SCRIPT_ARRAY+=("./vhdbuilder/packer/test/run-test.sh")
else
echo -e "\n\nSkipping tests for CVM 20.04"
fi

if [ "$OS_VERSION" != "18.04" ]; then
# Setup scanning
echo -e "\nENVIRONMENT is: ${ENVIRONMENT}, OS_VERSION is: ${OS_VERSION}"
if [ "${ENVIRONMENT,,}" != "prod" ] && [ "$OS_VERSION" != "18.04" ]; then
echo -e "Running scanning step"
SCRIPT_ARRAY+=("./vhdbuilder/packer/vhd-scanning.sh")
else
# 18.04 VMs don't have access to new enough 'az' versions to be able to run the az commands in vhd-scanning-vm-exe.sh
echo -e "\n\nSkipping scanning for 18.04"
echo -e "Skipping scanning step"
fi

echo -e "Running the following scripts: ${SCRIPT_ARRAY[@]}\n"
echo -e "\nRunning the following scripts: ${SCRIPT_ARRAY[@]}\n"
declare -A SCRIPT_PIDS
for SCRIPT in "${SCRIPT_ARRAY[@]}"; do
retrycmd_if_failure 2 3 "${SCRIPT}" &
Expand Down

0 comments on commit 9fc9126

Please sign in to comment.