From 9fc9126631e51c68b489a87c950ece71bc3259dd Mon Sep 17 00:00:00 2001 From: Cameron Meissner Date: Mon, 26 Aug 2024 10:47:07 -0700 Subject: [PATCH] chore: skip VHD scanning during official builds (#4865) Co-authored-by: Cameron Meissner --- .../templates/.builder-release-template.yaml | 1 + vhdbuilder/packer/test-scan-and-cleanup.sh | 16 +++++++++++----- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/.pipelines/templates/.builder-release-template.yaml b/.pipelines/templates/.builder-release-template.yaml index 9a38bcc7107..8ba55f73d1a 100644 --- a/.pipelines/templates/.builder-release-template.yaml +++ b/.pipelines/templates/.builder-release-template.yaml @@ -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} \ diff --git a/vhdbuilder/packer/test-scan-and-cleanup.sh b/vhdbuilder/packer/test-scan-and-cleanup.sh index 618d833581d..fd2ff1980fa 100755 --- a/vhdbuilder/packer/test-scan-and-cleanup.sh +++ b/vhdbuilder/packer/test-scan-and-cleanup.sh @@ -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 @@ -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 \ @@ -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}" &