deal with tagged commit if available for image tagging
For image tagging:
-
${CI_COMMIT_TAG}
- First tries to use the git tag if one exists - :- - This is the fallback operator that means "use the following value if the previous one is empty or unset"
-
$CI_COMMIT_SHORT_SHA
- The fallback value, which is the shortened git commit hash
So in practice:
- If you run a pipeline on a tagged commit (e.g., v1.2.3)
${CI_COMMIT_TAG:-$CI_COMMIT_SHORT_SHA}
evaluates to that tag (e.g., "v1.2.3") - If you run a pipeline on an untagged commit,
${CI_COMMIT_TAG}
is empty, so it falls back to$CI_COMMIT_SHORT_SHA
(e.g., "a7e3d0c")