Easy Answer
For a while TeamCity has supported VCS Labeling, this allows your VCS Root user (if it has write permissions) to tag the commit hash that was just built with the version or anything else TeamCity knows about (see entire list of parameter references in the TeamCity wiki).
An aside
As stated in another answer the Automatic Merge functionality available in TeamCity will automatically perform a merge into a requested branch from the specified list of branches (wildcard enabled) and it will monitor and build and only merge them if it succeeds.
The Automatic Merge functionality can be good, but if you don't have good test coverage it can also be dangerous as a developer could break something that doesn't have a test and that will cause issues in your code long down the road. One way to prevent this is to require +2 tests be created/run every time the project builds (configurable in TeamCity). These caveats are mentioned in the previously linked article announcing the Automatic Merge feature.
Related Resolution
We encountered a similar issue not related directly to merging, but having a requirement to push some changes from the job beyond the "lightweight tags" (for Git at least) that TeamCity adds if you use VCS Labeling (terrible name).
What we ended up doing was:
- Using a Parameter of the type "Environment Variable" (visible to the build agent, the other types are not) and setting the "Spec" to make the field of type "Password" which will prevent the entered text from showing in either the config UI or the Job log output.
- Entered the username and password as parameters on the job config
- Created a script that looked at the git remote URL of the "agent side" repository and added a new remote with the username and password inline in the url (http://gituser:gitpassword@githost.com/path/to/repo.git) in order to push the changes on a new branch.
- We then remove the remote at the end of the script so that anyone accessing the system can't pull out the credential. Of course the credential is also fairly tightly scoped to only access certain repositories, but the least privilege rule is always good to follow.