tcWebHooks: filter mismatch when using default quick filter Default VSC Branch only

Expected Behavior

Quick filter: works out of the box

Current Behavior

When adding the quick filter Default VSC Branch only, no notification are sent and the following error is reported 702 :: Filter mismatch: ${branchIsDefault} (${branchIsDefault}) does not match using regex true

I’m pretty sure it used to works, so it might be related to the TC server version. I first had tcWebHooks Version: 1.20 but I also installed the latest stable release 1.25 and it shows the same behavior.

Steps to Reproduce (for bugs)

  1. Create a Webhook to trigger when build fails
  2. Add the quick filter Default VSC Branch only

Your Environment

  • tcWebHooks Version: 1.25
  • TeamCity Version: 2023.11.3 (build 147512)
  • TeamCity server Operating System: Windows Server 2016
  • Are you using a WebHook Template?: Microsoft Teams (JSON Standard template)

Example Configuration (xml)

<?xml version="1.0" encoding="UTF-8"?>
<settings>
  <webhooks enabled="true">
    <webhook id="id_252346741" url="<removed>" enabled="true" template="microsoft-teams" hide-secure-values="true">
      <states>
        <state type="buildAddedToQueue" enabled="true" />
        <state type="buildRemovedFromQueue" enabled="true" />
        <state type="buildStarted" enabled="true" />
        <state type="changesLoaded" enabled="true" />
        <state type="buildInterrupted" enabled="true" />
        <state type="beforeBuildFinish" enabled="true" />
        <state type="buildFinished" enabled="true" />
        <state type="buildSuccessful" enabled="false" />
        <state type="buildFailed" enabled="true" />
        <state type="buildFixed" enabled="false" />
        <state type="buildBroken" enabled="false" />
        <state type="responsibilityChanged" enabled="true" />
        <state type="buildPinned" enabled="true" />
        <state type="buildUnpinned" enabled="true" />
        <state type="reportStatistics" enabled="false" />
        <state type="serviceMessageReceived" enabled="true" />
      </states>
      <build-types enabled-for-all="false" enabled-for-subprojects="false">
        <build-type id="bt26667" />
        <build-type id="bt26671" />
        <build-type id="bt26672" />
      </build-types>
      <trigger-filters>
        <filter value="${branchIsDefault}" regex="true" enabled="true" />
      </trigger-filters>
    </webhook>
  </webhooks>
</settings>

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 16 (9 by maintainers)

Most upvoted comments

Here are a couple of things you could try. I can’t easily get a value that doesn’t exist, other than referring to values that are non-existent. However, this means that I can’t test both positive and negative scenarios.

In this first example we utilise regex’s negative lookahead to look for something that does not contain .+ (which means at least one character). In other words, something that is empty. ${teamcity.build.something.nonexistant} :: ^(?!.+)$

However, this might not work because the template engine (Standard) used by the MS Teams template will actually return UNRESOLVED for any variable it can’t resolve. If this was a Velocity template, that would probably have been the correct approach.

With this information, we can actually look for “UNRESOLVED” and you might have better success. ${teamcity.build.something.nonexistant} :: UNRESOLVED

In my testing this appears to work.

So for you, you could try ${teamcity.build.branch} :: UNRESOLVED

eg,

image