This works on my side:
steps:
- checkout: self
persistCredentials: true
# Rest of the pipeline
- script: |
git config --global user.name "BuildService"
git config --global user.email "[email protected]"
git tag "Build_$(Build.BuildNumber)"
git push origin --tags
workingDirectory: '$(Build.Repository.LocalPath)'