Skip to content

Commit 6b1dfbb

Browse files
committed
Add handling for git tags in Konflux
1 parent 6e75b71 commit 6b1dfbb

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

.tekton/determine-image-tag-task.yaml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,15 @@ spec:
4141
dnf -y install git make
4242
4343
scripts/konflux/fail-build-if-git-is-dirty.sh
44-
echo -n "$(make --quiet --no-print-directory tag)$(params.TAG_SUFFIX)" | tee "$(results.IMAGE_TAG.path)"
44+
45+
# First, try take git tag if it's a tagged commit.
46+
tag="$(git tag --points-at)"
47+
if [[ -z "$tag" ]]; then
48+
# If not, use make target's output.
49+
tag="$(make --quiet --no-print-directory tag)"
50+
elif [[ "$(wc -l <<< "$tag")" -gt 1 ]]; then
51+
>&2 echo -e "Error: the HEAD commit has multiple tags, don't know which one to choose:\n$tag"
52+
exit 5
53+
fi
54+
55+
echo -n "${tag}$(params.TAG_SUFFIX)" | tee "$(results.IMAGE_TAG.path)"

0 commit comments

Comments
 (0)