arrow-rightgithublinkedinscroll-to-topzig-zag

Configure TeamCity to use a Webhook

Last Updated On

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:

  1. It produces unnecessary load on version control server.
  2. 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:

https://user:password@teamcityUrl:port/httpAuth/action.html?add2Queue=build_id

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 

Conclusion

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.