Skip to content

Commit

Permalink
chore: set image version variable within scanning (#5591)
Browse files Browse the repository at this point in the history
  • Loading branch information
jason1028kr authored Jan 24, 2025
1 parent 2343477 commit fface89
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
1 change: 1 addition & 0 deletions vhdbuilder/packer/trivy-scan.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export BUILD_SOURCEVERSION=${25}
export SYSTEM_COLLECTIONURI=${26}
export SYSTEM_TEAMPROJECT=${27}
export BUILD_BUILDID=${28}
export IMAGE_VERSION=${29}

retrycmd_if_failure() {
retries=$1; wait_sleep=$2; timeout=$3; shift && shift && shift
Expand Down
10 changes: 9 additions & 1 deletion vhdbuilder/packer/vhd-scanning.sh
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,13 @@ TRIVY_UPLOAD_TABLE_NAME="trivy-table-${BUILD_ID}-${TIMESTAMP}.txt"

# Extract date, revision from build number
BUILD_RUN_NUMBER=$(echo $BUILD_RUN_NUMBER | cut -d_ -f 1)

# set image version locally, if it is not set in environment variable
if [ -z "${IMAGE_VERSION:-}" ]; then
IMAGE_VERSION=$(date +%Y%m.%d.0)
echo "IMAGE_VERSION was not set, setting it to ${IMAGE_VERSION} for trivy scan and Kusto ingestion"
fi

az vm run-command invoke \
--command-id RunShellScript \
--name $SCAN_VM_NAME \
Expand Down Expand Up @@ -127,7 +134,8 @@ az vm run-command invoke \
"BUILD_SOURCEVERSION"=${BUILD_SOURCEVERSION} \
"SYSTEM_COLLECTIONURI"=${SYSTEM_COLLECTIONURI} \
"SYSTEM_TEAMPROJECT"=${SYSTEM_TEAMPROJECT} \
"BUILDID"=${BUILD_ID}
"BUILDID"=${BUILD_ID} \
"IMAGE_VERSION"=${IMAGE_VERSION}

capture_benchmark "${SCRIPT_NAME}_run_az_scan_command"

Expand Down

0 comments on commit fface89

Please sign in to comment.