diff --git a/functions.sh b/functions.sh index 45812a8dab75..6015704d58dd 100644 --- a/functions.sh +++ b/functions.sh @@ -60,7 +60,7 @@ sonic_get_version() { BUILD_NUMBER=${BUILD_NUMBER:-0} ## Check if we are on tagged commit ## Note: escape the version string by sed: / -> _ - if [ "$describe" == "$latest_tag" ]; then + if [ -n "$latest_tag" ] && [ "$describe" == "$latest_tag" ]; then echo "${latest_tag}${dirty}" | sed 's/\//_/g' else echo "${branch_name}.${BUILD_NUMBER}${dirty:--$(git rev-parse --short HEAD)}" | sed 's/\//_/g'