Skip to content
netwolfuk edited this page Jul 15, 2025 · 4 revisions

Since tcWebHooks-3.0.0-alpha.1

Since 3.0.0, WebHooks are defined in TeamCity as ProjectFeatures. We define project features in TeamCity's Kotlin DSL inside our project's settings.kts file. Within this file we need to place them in the features block, which is in turn located within the project block.

Placement of WebHooks in settings.kts

// TeamCity Project definition
project {
    // Features are defined within a project
    features {
        // webhooks are defined as features.
        webHookConfiguration {
            // webhook definition
        }
        webHookConfiguration {
            // a second webhook definition
        }
    }
}

Defining a WebHook

The minimum attributes required are webHookId template, url, buildTypes, and buildStates.

webHookConfiguration {
    /*
     * webHookId must be unique across all of teamcity.
     * A simple way to guarantee this is to base the name on the current project, and use a number
     */
    webHookId = "RootProjectId_WebHook_01"

    /*
     * template refers to the ID of a template.
     * The Template ID is at the top of the template page for viewing a template. 
     */
    template = "legacy-json"

    /*
     * url is the web address of where to deliver the webhook POST request.
     */
    url = "http://localhost:8111/webhooks/endpoint.html?vcs_test=1"

    /*
     * builsTypes define which builds will trigger this webhook
     * 
     */
    buildTypes = allProjectBuilds {
        subProjectBuilds = true
    }
    buildStates {
        buildAddedToQueue = true
        buildRemovedFromQueue = true
    }
}

Clone this wiki locally