# check-for-changes-teamcity change-commit //depot/. Set up a change-commit trigger by adding the following line when editing the specification with the `p4 triggers` command: Save the script on the Perforce server under the name /path/teamcity-hook.sh. Save this script on your Perforce server as teamcity-hook.sh: If such a connection is not configured explicitly, TeamCity will try to connect to Perforce using settings of one of the project's VCS roots. TeamCity will use it to ensure that all changed files in the Perforce changelist are collected. It is also recommended configuring a Perforce Administrator Access connection in the project settings. This permission is included in the Project Developer role by default.
The TeamCity user assigned to this token must have the " Run build" permission for projects where Perforce VCS roots are defined. To be able to use the script, you need to generate an access token first. This script will autodetect Perforce VCS roots in TeamCity and trigger the respective builds.
You can install the dedicated post-commit script on your Perforce server. There are two ways to set up a post-commit hook in Perforce: Setting up post-commit hook on Perforce server To match more, count:99999 can be added as below.Ĭhmod 755 /path/to/teamcity-trigger.sh /path/to/svn_repository_root/hooks/post-commit Note that by default only the first 100 VCS root instances will be matched by the request. The request should be performed by a user who has the " View project and all parent projects" permission for all the projects where the VCS root is defined. Some examples of the "locator" are provided below. If too many VCS roots are matched by the request configured in the commit hook, it will lead to more requests and more overload on the VCS repository and TeamCity than using the default polling approach. It is important to find for the request to match only the affected VCS roots from those configured in the TeamCity instance. The request returns textual details as to the performed operation or an error message. app/rest/vcs-root-instances/commitHookNotification?locator= If the commit hook stops working (for example, TeamCity finds a change in a VCS root which it did not receive a commit hook call for), the VCS polling interval value is reset to default.Ĭommit hooks are received via TeamCity REST API requests which should typically be configured in the post-commit repository triggers: If a change is found during the check, TeamCity automatically increases the VCS polling interval (the minimum after the increase is 15 minutes, maximum is 4 hours, increased by 2 times on each successful check). When a commit hook call comes in, TeamCity starts checking for changes in VCS roots which match the request. If you are using GitHub, try the external TeamCity Commit Hooks plugin OverviewĮven with commit hooks configured and working properly, TeamCity still makes requests for changes on the server start and on each build queuing (or starting) to ensure the latest changes are used even if commit hooks stopped to function. This way, TeamCity will make background requests for changes detection only when such changes are available.
To avoid background polling, it is possible to set up a post-commit hook on the VCS server, which will notify TeamCity to start checking for changes procedure.
For large installations with hundreds of VCS roots, this may create a noticeable load on the VCS server and on TeamCity. It periodically sends requests to the version control repository server to find out whether there are new revisions. Configuring VCS Post-Commit Hooks for TeamCityīy default, TeamCity uses a polling approach to detect changes in a VCS repository, that is for each VCS root.