VCS root. Hash of a commit as branch
Hello. I have existing TC configuration. Default branch for VCS root configured as `refs/heads/%PARAMETER%`. When running build I provide branch name as `PARAMETER` and everything works fine.
If I pass commit hash instead of branch name build fails with `Failed to collect changes, error: Cannot find revision of the default branch`.
Is there a way to configure VCS root that it will accept both branch names and commit hashes?
Please sign in to leave a comment.
Hi Sergey,
at the moment, it's not possible to tell TeamCity to build an arbitrary commit by passing it as a parameter. Please vote for this issue on the tracker: https://youtrack.jetbrains.com/issue/TW-5610
It is though possible to choose a specific commit in the VCS history that has been tracked by TeamCity, though, although in your setup it might be a bit harder. While using parameters in vcs roots is fine, recommended even, the specification (or default branch) is meant for teamcity to know which branches to track. Changing it for every build usually messes with TeamCity's data and makes it harder to use some advanced features such as revision history. It's usually recommended to not change those parameters on a per-build basis (change them based on projects, when new are needed, olds stop being useful, etc), to run builds on specific branches you can still do it by specifying all the branches that should be tracked, then letting teamcity collect the information and you can use them as you need.
Once TeamCity can keep tracking the branches normally, you can click on the ellipsis (the "…" symbol next to the "Run" button) to open a custom build, and choosing "Changes", you can specify any branch or any previous commit that has been tracked by TeamCity previously. Keep in mind that commits done before the VCS Root was added at all to TeamCity will not be tracked and build-able in this way.
There is a third option, which would be to tell TeamCity to not check out files automatically, and pass the revision manually as a parameter, then use this parameter in a first build step to manually script your way to obtain the commit you are looking for.
Hello Denis,
Thank you