Branch name may contain slashes, so it should be: branch=`echo $ref | cut -d/ -f3-`
branch=`echo $ref | cut -d/ -f3-`
Branch name may contain slashes, so it should be:
branch=`echo $ref | cut -d/ -f3-`