Skip to content

Customising the buildStatusHtml Message

netwolfuk edited this page Apr 11, 2016 · 2 revisions

This method is deprecated because only allows you to change the contents of the buildStatusHtml. It's much more useful to define a property of any name and use that.

By default, the payload from tcWebHooks contains an entry called "htmlBuildStatus". This is an HTML message that contains some information about the build result and links back to the TeamCity server.

The contents of this entry can be customised by declaring a custom template inside a webhook configuration. Currently, this cannot be edited using the UI, but that is on the roadmap. In the mean time, here is an example configuration adding branch information into the message. Unfortunately, it's HTML embedded inside XML, so all the HTML tags need to be escaped.

	<custom-templates>
		<custom-template type='buildStatusHtml' template='&lt;span class="tcWebHooksMessage"&gt;&lt;a href="${rootUrl}/project.html?projectId=${projectId}"&gt;${projectName}&lt;/a&gt; :: &lt;a href="${rootUrl}/viewType.html?buildTypeId=${buildTypeId}"&gt;${buildName}&lt;/a&gt; # &lt;a href="${rootUrl}/viewLog.html?buildTypeId=${buildTypeId}&amp;buildId=${buildId}"&gt;&lt;strong&gt;${buildNumber} : ${env.teamcity_build_branch}&lt;/strong&gt;&lt;/a&gt; has &lt;strong&gt;${buildStateDescription}&lt;/strong&gt; with a status of &lt;a href="${rootUrl}/viewLog.html?buildTypeId=${buildTypeId}&amp;buildId=${buildId}"&gt; &lt;strong&gt;${buildResult}&lt;/strong&gt;&lt;/a&gt; and was triggered by &lt;strong&gt;${triggeredBy}&lt;/strong&gt;&lt;/span&gt;' enabled='true' />
	</custom-templates>

It might be easier to view the code on pastebin: http://pastebin.com/QzBmgqK8

The reason the variable is called "buildStatusHtml" is because that the keyword that HipChat used way back in the day. Version 1 of the HipChat API looked for this form encoded variable in the POST request from tcWebHooks.

There are a number of blog posts about customising payload content:

Hopefully soon, this page will be redundant, and messages (and templates) will be able to be edited in the UI.

Clone this wiki locally