By default, TeamCity will use a pulling. It means that it will go to the VCS periodically and look for any updates. The standard setting is 60 seconds. However, it's not a best practice to use a pull, because:
- It produces unnecessary load on version control server.
- Long waiting period after each push. On average you should wait 30 seconds before TeamCity will notice the change and trigger a build. Having a delay with 30 seconds is infiniteness.
Starting from version 8.1 TeamCity ships with its own REST API. Basically, you need to send a POST request with the following format:
The URL above can be used to register a Webhook on each Repository push.
It's a good idea to create a separate user for this need.
However, TeamCity will still do a pull, because we didn't disable periodic checking. By the time I'm writing this article there is no option to completely disable pull, but we can set checking time interval to 99999999 seconds, which is ~3 years and can be treated as eternity in our case.
Go to build configuration and set
By settings up a Webhook, we were able to reduce the load on version control system server and save deployment time by having an immediate build triggering.