Skip to content

Commit a844e2a

Browse files
Enhance image tag validation in deployment scripts for SemVer compliance (#1569)
Co-authored-by: rambhatt <rambhatt@microsoft.com>
1 parent 36bcca3 commit a844e2a

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

.pipelines/azure_pipeline_validation_appmonitoring.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@ jobs:
5353
## preview release are in format preview-Major.Minor.Patch
5454
- bash: |
5555
commit=$(git describe --tags --abbrev=0)
56-
imageTag="$commit"
56+
# Remove 'appmonitoring-' prefix if present for SemVer compatibility
57+
imageTag="${commit#appmonitoring-}"
5758
5859
echo "imageTag is $imageTag"
5960

deployment/mergebranch-webhook-deployment/ServiceGroupRoot/Scripts/pushOciChartsToAcr.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@ fi
3232
TAG_EXISTS_STATUS=0 #Default value for the condition when the echo fails below
3333
AZ_ACR_IMPORT_FORCE=""
3434

35+
if [[ ! "$SOURCE_IMAGE_TAG" =~ ^[0-9][0-9A-Za-z\.-]*$ ]]; then
36+
echo "-e error SOURCE_IMAGE_TAG must start with a digit and may only contain 0-9, A-Z, a-z, '.', or '-'"
37+
echo "SOURCE_IMAGE_TAG was: $SOURCE_IMAGE_TAG"
38+
exit 1
39+
fi
3540

3641
TAG="$SOURCE_IMAGE_TAG-rc.$SOURCE_IMAGE_BUILD_ID"
3742
if [[ "$TAG" =~ ^(.+)-rc\.[0-9]+$ ]]; then

deployment/mergebranch-webhook-deployment/ServiceGroupRoot/Scripts/pushWebhookToAcr.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ fi
1515
TAG_EXISTS_STATUS=0 #Default value for the condition when the echo fails below
1616
AZ_ACR_IMPORT_FORCE=""
1717

18+
if [[ ! "$SOURCE_IMAGE_TAG" =~ ^[0-9][0-9A-Za-z\.-]*$ ]]; then
19+
echo "-e error SOURCE_IMAGE_TAG must start with a digit and may only contain 0-9, A-Z, a-z, '.', or '-'"
20+
echo "SOURCE_IMAGE_TAG was: $SOURCE_IMAGE_TAG"
21+
exit 1
22+
fi
1823

1924
TAG="$SOURCE_IMAGE_TAG-rc.$SOURCE_IMAGE_BUILD_ID"
2025
if [[ "$TAG" =~ ^(.+)-rc\.[0-9]+$ ]]; then

0 commit comments

Comments
 (0)