Building tcWebHooks custom parameters from teamcity build parameters

Posted on Updated on

Custom Parameters are a feature in the tcWebhooks plugin, which allow one to send a custom string to the webhook endpoint made up of a template and variables.

Up until today, those variables have only included other values from the webhook’s payload. However, from now on it is also possible to use build paramters from the TeamCity build configuration. One now has access to the TeamCity build properties. These include properties defined by the build configuration, as well as env.*, teamcity.* and system.* properties.

An example is worth a thousand pictures

        <param name="aaa_param" value="TeamCity version ${system.teamcity.version} running as user ${env.LOGNAME}" />

This example parameter will add an item as per the table below.

Name Value
aaa_param TeamCity version 8.1.4 (build 30168) running as user netwolfuk

Using the TeamCity build parameters to create Custom Webhook Parameters

Additionally, any property beginning with the string “webhook.” will automatically be included in the webhook payload with the “webhook.” prefix removed. This allows custom parameters to be declared from the Teamcity build parameters rather than having to edit the webhooks plugin XML file. The above example could then be configured as per the following screenshot.

Screenshot from 2014-09-23 09:27:07
Download the version (or higher) from sourceforge to try it out.

The build parameters configuration in Teamcity is explained on the TeamCity configuration properties wiki page. More info about using tcWebHooks custom parameters is also available.

3 thoughts on “Building tcWebHooks custom parameters from teamcity build parameters

    ʎʞsʌǝʃıssɐʌ (@vassilevsky) said:
    September 23, 2014 at 08:45

    Thank you for the update. I use the plugin to report build failures to Flowdock. I have installed version and added project parameters webhook.* (those required by Flowdock). It works fine.

    Before that, I tried to locate the .BuildServer directory you were talking about, to edit the XML file, but I couldn’t find any. I am running TeamCity server in a Docker container from the image conveniently provided by Ariya Hidayat:

    I used nsenter program to run bash inside the container and searched everywhere with `find / -name ‘.BuildServer’` but it found nothing. So, this new parameters support is a life saver 🙂

      netwolfuk responded:
      September 23, 2014 at 09:08

      Thanks for your feedback, and exciting to see Docker and TeamCity in action.

      netwolfuk responded:
      September 23, 2014 at 17:11

      It looks like the TeamCity data directory is configured as /data/teamcity on that docker image according to the source.
      If you look in /data/teamcity there should be a config dir (and plugins, etc). This is where the config would be stored. However, as you said it’s no longer an issue since you can now control the parameters in the build configuration.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s