Skip to content

WebHook Templates : webhook templates xml

netwolfuk edited this page May 4, 2018 · 6 revisions

tcWebHooks comes with some webhook templates bundled in the release, but its possible to override those with different content, or create new templates.

Bundled templates are inside the plugin ZIP file, but user-defined templates are stored locally on the TeamCity server in a file called webhook-templates.xml. This file is written to when changes are made to templates via the Web UI (which uses the REST API to perform any edits), but its also possible to make modifications to the file itself on the filesystem on the server.

Any changes made by editing the file will be reloaded automatically within a few seconds of editing the file. If the file is syntactically incorrect, it will not be parsed and will log messages in the teamcity-server.log.

To avoid any issues with syntax, it is recommended that webhook template modifications are performed by the Web UI.

The webhook-templates.xml is stored in BuildServer/config on the server. BuildServer is the TeamCity Data Directory. If no local webhook templates have been created or edited, the webhook-templates.xml file may not exist, and will need to be created if you want to manually edit it.

Here is a very simple example of the webhook-templates.xml file. It is simply a <webhook-templates> XML element with one or more <webhook-template> elements inside it.

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<webhook-templates>
    <webhook-template id="a-test-template" enabled="true" rank="100" format="jsonTemplate">
        <default-template use-for-branch-template="false">{}</default-template>
        <default-branch-template>{}</default-branch-template>
        <template-description>A Test Template</template-description>
        <preferred-date-format></preferred-date-format>
        <templates max-id="1">
            <template id="0">
                <template-text use-for-branch-template="true">{}</template-text>
                <branch-template-text>{}</branch-template-text>
                <states>
                    <state type="buildSuccessful" enabled="true"/>
                    <state type="buildFailed" enabled="true"/>
                    <state type="responsibilityChanged" enabled="true"/>
                </states>
            </template>
        </templates>
    </webhook-template>
</webhook-templates>

To understand the elements inside a webhook template, see the WebHook-Templates-:-Anatomy-of-a-Template page. For more examples of <webhook-template> items, see the bundled webhook templates here

Clone this wiki locally