Created
October 23, 2025 23:26
-
-
Save Romiko/85bda5cd1c33a705a1026a7b8c211067 to your computer and use it in GitHub Desktop.
Image versioning
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| - task: Bash@3 | |
| name: SetAppVersion | |
| displayName: 'Prepare version + image tags' | |
| inputs: | |
| targetType: 'inline' | |
| script: | | |
| set -euo pipefail | |
| # Expect appVersion like 1.0.13 (SemVer MAJOR.MINOR.PATCH) | |
| if [[ -z "${appVersion:-}" ]]; then | |
| echo "##vso[task.logissue type=error]appVersion variable is empty. Set it (e.g. via variable group, template, or file)." | |
| exit 1 | |
| fi | |
| if [[ ! "$appVersion" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then | |
| echo "##vso[task.logissue type=error]appVersion '$appVersion' is not SemVer MAJOR.MINOR.PATCH (e.g. 1.0.13)." | |
| exit 1 | |
| fi | |
| IFS='.' read -r MAJOR MINOR PATCH <<< "$appVersion" | |
| majorMinorTag="${MAJOR}.${MINOR}" | |
| ciTag="${appVersion}-${BUILD_BUILDID}" | |
| echo "Primary image tag : $appVersion" | |
| echo "Traceability CI tag : $ciTag" | |
| echo "Major tag : $MAJOR" | |
| echo "Major.Minor tag : $majorMinorTag" | |
| # Export variables for later tasks | |
| echo "##vso[task.setvariable variable=PrimaryImageTag]$appVersion" | |
| echo "##vso[task.setvariable variable=CiImageTag]$ciTag" | |
| echo "##vso[task.setvariable variable=MajorTag]$MAJOR" | |
| echo "##vso[task.setvariable variable=MajorMinorTag]$majorMinorTag" | |
| # Keep ADO build number traceable in the UI | |
| echo "##vso[build.updatebuildnumber]$ciTag" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| - task: Docker@2 | |
| displayName: 'Build & Push' | |
| inputs: | |
| command: buildAndPush | |
| repository: 'alh-hotelsloyalty-affiliationservice' | |
| Dockerfile: '**/Dockerfile' | |
| containerRegistry: '$(dockerServiceConnection)' | |
| tags: | | |
| $(PrimaryImageTag) | |
| $(CiImageTag) | |
| $(MajorMinorTag) | |
| $(MajorTag) | |
| latest |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment