-
Notifications
You must be signed in to change notification settings - Fork 28
Applying Filtering Criteria To WebHook Execution
Trigger Filtering applies a regular expression (regex) match before executing a webhook.
Filters are defined by editing the plugin-settings.xml
file on the server and adding a <trigger-filters>
element containing one or more <filter/>
sub-elements.
If multiple <filter/>
elements are present, then they must all match before the webhook would be executed.
Here is an example which would allow the webhook to be POST'd if both branchDisplayName equals "master" and buildInternalTypeId equals "bt" followed by a number (eg, "bt9").
<trigger-filters>
<filter value="${branchDisplayName}" regex="^master$" enabled="true"/>
<filter value="${buildInternalTypeId}" regex="^bt\d$" enabled="true"/>
</trigger-filters>
The value can be any string, but it's most useful to match against a webhook variable.
The regex is applied to the whole string (so the ^
and $
in the above example are superflous).
This means that if one wants to match on a substring, the regex should include some sort of wildcard match.
The following is a sub-string match example, which would match "master" because it contains the sub-string "aste".
<filter value="${branchDisplayName}" regex=".+aste.+" enabled="true"/>
There are more examples on the Advanced Editing of tcWebHooks configuration page.
This shows a <trigger-filters>
element in context of a webhook configuration.
<?xml version="1.0" encoding="UTF-8"?>
<settings>
<webhooks enabled="true">
<webhook url="http://localhost:58001/200" enabled="true" format="JSON">
<states>
<state type="buildStarted" enabled="true" />
<state type="changesLoaded" enabled="true" />
<state type="beforeBuildFinish" enabled="true" />
<state type="buildFinished" enabled="true" />
<state type="buildBroken" enabled="false" />
<state type="buildInterrupted" enabled="true" />
<state type="buildSuccessful" enabled="true" />
<state type="buildFixed" enabled="false" />
<state type="buildFailed" enabled="true" />
<state type="responsibilityChanged" enabled="true" />
</states>
<trigger-filters>
<filter value="${branchDisplayName}" regex="^master$" enabled="true"/>
<filter value="${buildInternalTypeId}" regex="^bt\d$" enabled="true"/>
</trigger-filters>
<parameters>
<param name="color" value="red" />
<param name="notify" value="1" />
</parameters>
</webhook>
</webhooks>
</settings>
- Home
- Installing
- Configuration
- Templates
- Parameters (aka Variables)
- Example Webhook output
- WebHooks REST API