Gradle do not have direct command to get version of project.

From linux terminal you can get like

gradle properties -q | grep "version:" | awk '{print $2}'

To use inside shell script

project_version=$(gradle properties -q | grep "version:" | awk '{print $2}' | tr -d '[:space:]')
echo $project_version