Closed matt-richardson closed 1 year ago
Hi @matt-richardson. Thanks for your detailed report (as per usual).
If I remember correctly, the list of tests was not available for muted.
I'll have a look at your suggestion just in case I missed something obvious.
Thanks @matt-richardson. It looks like your suggestion works.
I've pushed to a branch here: https://teamcity.jetbrains.com/buildConfiguration/WebHooksAndOtherPlugins_TcWebHooks?branch=issue_219-muted-tests&buildTypeTab=overview&mode=builds
Can you give that a try and I'll look to do so a release later this week if it all goes well.
Hmm. ~~Looking at the code in that file on line 121, I don't think it ever worked for muted.
It checks for a non-empty list of tests before executing the webhook. School boy error. 🫣~~
Ignore. It's too late. I'm not being sense.
Happy to report that it works successfully for both muted and unmuted now :success:.
derivedBuildEventType | TESTS_MUTED
mutedOrUnmutedTests | {13=[suiteName: nestedSuiteName: package_or_namespace.ClassName.TestName]}
derivedBuildEventType | TESTS_UNMUTED
mutedOrUnmutedTests | {11=[suiteName: nestedSuiteName: package_or_namespace.ClassName.TestName]}
~Another question with this... What is the 13=
and 11=
on these?~
~I'm using the legacy / deprecated name value pairs format to get these, so it may just be a side affect of that, but not entirely sure how they'll format in json?~
Nevermind: figured it out... It's the default .toString()
implementation of MuteInfo
- it just renders the id.
I imagine it the result of calling toString
on that value.
This is what I get.
I am doing the following in velocity
## Define macro called "showTests"
#macro( showTests $myTests)
#if ( $myTests.size() > 0 )
#foreach( $tests in $myTests.keySet() )##
#foreach( $test in $tests.getTests() )##
• #escapejson($test.name)
#end
#end
#else No Changes found #end
#end
It prints the bulleted list in the following screenshot when posted to Slack.
I am looking at exactly that file right now :)
I've successfully got this all working to my needs - I'm now able to get hooks with:
{
"event": "TESTS_UNMUTED",
"tests": [
{
"name": "suiteName: nestedSuiteName: package_or_namespace.ClassName.TestName",
"id": "-8186798926076262107",
"user": "matt@example.com"
}
]
}
and
{
"event": "TESTS_MUTED",
"tests": [
{
"name": "suiteName: nestedSuiteName: package_or_namespace.ClassName.TestName",
"id": "-8186798926076262107",
"user": "matt@example.com"
}
]
}
For posterity, this is based on the following template:
{
"event": "$buildEventType",
"tests": [
#foreach( $entry in $mutedOrUnmutedTests.entrySet() )##
#foreach( $test in $entry.value )##
{
"name": "#escapejson($test.name)",
"id": "$test.testNameId",
"user": "$entry.key.mutingUser.username"
}#if( $foreach.hasNext ),#end
#end
#end
]
}
Nice work. Thanks for the update. I'll get a new release out over the weekend. Thanks for your help on this.
@matt-richardson If you get a chance, you could pop those into https://github.com/tcplugins/tcWebHooks/wiki/WebHook-Templates-%3A-The-Velocity-Templating-Engine
Good call - I've updated the wiki 👍
Looks like 1.2.3 is out - I'll give that a go.
Very nice. I like the foreach.hasNext
to conditionally add the closing comma.
Thanks again. I think we can close this ticket.
FYI. If you're interested in sharing a working template set, there is a project here: https://github.com/tcplugins/tcWebHooksTemplates
I really really need to update the instructions on that repo for exporting and importing templates, as it's all possible via the GUI now. No more curl and crazy REST malarky.
I've updated the instructions at https://github.com/tcplugins/tcWebHooksTemplates
I know I shouldn't add onto a closed issue, but.... i'm going to anyway :joy:
Im seeing a bunch of errors:
[2023-07-18 02:16:17,787] ERROR [@7438424f'; Normal executor 28] - jetbrains.buildServer.SERVER - AbstractWebHookExecutor :: trackingId: dadfab32-86b1-4bab-8c1a-afd38e6870e4 :: projectId: OctopusDeploy_OctopusServer_CorePlatform :: webhookId: id_905369674 :: templateId: buildmonitormutes, errorCode: 902, errorMessage: Template 'buildmonitormutes' does not support build state 'beforeBuildFinish'
The template is configured like this:
But the webhook is showing all the boxes as ticked, but disabled:
Am I holding it wrong?
Looks like a UI issue. Can you please raise as a new ticket? I think it's because the template was re-selected in the UI from one that did support all event types, hence are selected but disabled.
You might be able to work around by opening and saving and opening the webhook again.
I'm checking out the new test muted and test unmuted events, to see how we can tie this into our other systems.
For unmuted, we get the test name, but for muted, we dont get the test name.
Expected Behavior
(I'm not 100% sure what the
4
is about...)Current Behavior
Steps to Reproduce (for bugs)
Create a basic teamcity project, add a command line runner with the following content:
Add a webhook that triggers on mute and unmute. Mute / unmute the test.
Your Environment
Legacy Webhook (Name Value Pairs)
Investigation so far
Looking at the code, in WebhookListener.java, it creates a new map, but we could potentially change it from
to
and I think it should work... (Note that I haven't tested this at all)