I managed to resolve myself by adding build step with git commands. Below are the changes I had to do in my TeamCity Configuration.
- Changed VCS checkout mode: to Automatically on agent (if supported by VCS roots) in version control settings, original value was Automatically on server.
- Added Build step and set Choose Runner Type : Command Line, Step Name: "any of your choice, I used Apply Tag", Run : Custom Script, Custom script: *
git -c diff.mnemonicprefix=false -c core.quotepath=false tag -a -m comment tag1
git -c diff.mnemonicprefix=false -c core.quotepath=false push -v origin refs/tags/tag1
And last thing is add permission for the build agent account on your stash repository, otherwise I was getting permission error.