tcWebHooks icon indicating copy to clipboard operation
tcWebHooks copied to clipboard

Webhooks configured via Kotlin sees 701 :: WebHook not enabled for buildState 'buildFinished'

Open radiumsurfer opened this issue 7 months ago • 58 comments

Hi @netwolfuk I'm seeing a similar problem that may be related to https://github.com/tcplugins/tcWebHooks/issues/246

We're using kotlin for versioned settings, and (unless there's a better way, ideally IN kotlin would be great) configuring webhooks via configuring the file

Example Configuration (xml)

.teamcity/pluginData//plugin-settings.xml

<?xml version="1.0" encoding="UTF-8"?>
<settings>
    <webhooks enabled="true">
        <webhook url="http://<hook receiving endpoint>" enabled="true" format="json" template="none">
            <states>
                <state type="buildInterrupted" enabled="true" />
                <state type="buildFailed" enabled="true" />
                <state type="buildBroken" enabled="false" />
                <state type="responsibilityChanged" enabled="false" />
                <state type="buildSuccessful" enabled="true" />
                <state type="buildStarted" enabled="false" />
                <state type="beforeBuildFinish" enabled="false" />
                <state type="buildFixed" enabled="false" />
                <state type="buildFinished" enabled="true" />
                <state type="changesLoaded" enabled="false" />
            </states>
            <build-types enabled-for-all="false" enabled-for-subprojects="false">
                <build-type id="bt656500" />
            </build-types>
        </webhook>
    </webhooks>
</settings>

where build-type id fetched from the database table build_type_mapping

and in the UI it shows 0 in Enabled Builds image

This had been working fine until we've upgraded to teamcity 2023 to 2024, where we encountered https://github.com/tcplugins/tcWebHooks/issues/236 and upgraded to 2.0.1

Current Behavior

After applying the plugin without server restart, no hooks worked. After restarting the server, hooks for some builds seem to be working, then it stopped working. The event response for those are all

701 :: WebHook not enabled for buildState 'buildFinished'

This time another server restart does not resolve it. Again most but not all are broken, which is baffling. This is an example plugin-settings.xml of a build that does work.

<?xml version="1.0" encoding="UTF-8"?>
<settings>
    <webhooks enabled="true">
        <webhook url="http://<same endpoint as above" enabled="true" format="json" template="none">
            <states>
                <state type="buildInterrupted" enabled="true" />
                <state type="buildFailed" enabled="true" />
                <state type="buildBroken" enabled="false" />
                <state type="responsibilityChanged" enabled="false" />
                <state type="buildSuccessful" enabled="true" />
                <state type="buildStarted" enabled="false" />
                <state type="beforeBuildFinish" enabled="false" />
                <state type="buildFixed" enabled="false" />
                <state type="buildFinished" enabled="true" />
                <state type="changesLoaded" enabled="false" />
            </states>
            <build-types enabled-for-all="false" enabled-for-subprojects="false">
                <build-type id="bt656397" />
            </build-types>
        </webhook>
    </webhooks>
</settings>

I did a diff of the xmls and they are the same (except for build-type id). I have triple verified that the build-type ids are the correct ones in the db.

This one in the UI, Enabled Builds shows 1

image

The hooks configured via UI at the top level seem to be working fine.

From configuring a test hook in the UI, I noticed the format of the plugin-settings.xml has changed - also includes an id. Are new versions that fixes https://github.com/tcplugins/tcWebHooks/issues/236 backwards compatible?

I have tried turning on debug but didn't see much in the logs as to why "WebHook not enabled for buildState 'buildFinished'"

Expected Behavior

Hooks sent with 200 status

Steps to Reproduce (for bugs)

  1. Configure a kotlin project with above xml
  2. Launch build
  3. See if webhook is sent

Your Environment

  • tcWebHooks Version: 2.0.1 build 502
  • TeamCity Version: 2024.03.3
  • TeamCity server Operating System: RHEL
  • Are you using a WebHook Template?: No

Appreciate any help here, as hooks is pretty broken for our instance. Thank you

radiumsurfer avatar Jul 24 '24 17:07 radiumsurfer