Investigate Mute or Fix Test callback
amadeuszpolak opened this issue · 6 comments
Hi,
I would like to mark a failed test as Fixed and get some callback to be able re run the build again. Is is possible via tcWebHooks ?
Hi @amadeuszpolak.
tcWebHooks does not currently support this. I see there is a callback that I can use to detect when tests are muted. I'm not sure if this works for "fixed" too.
I can't see another on that page for "fixed tests", so I will try adding a dummy listener for the mute callback and see which events it fires on.
After that we can make a decision on whether we want to add a new build state for this to tcWebHooks.
I've done some testing, and can see a way to subscribe to muted/unmuted tests, but not Mark as Fixed.
I have raised a ticket with TeamCity support to see if I have missed something.
https://youtrack.jetbrains.com/issue/TW-79828/Listen-for-Tests-Mark-as-fixed-event-in-OpenAPI
Hi @amadeuszpolak The teamcity support team replied, and I am already listening for the responsibility changed event.
I have been able to trigger a build from marking the test as fixed. However, I found and fixed a bug that would sometimes stop ResponsibilityChanged from triggering.
Make sure you get the latest build from here. I just pushed the change, so the build should run shortly.
Once that is installed, this is what I did...
- Create a new JSON Velocity template that looks like the payload to queue a build.
{ "buildType": { "id": "${myBuildTypeId}" } }
- Create a token so that your user can trigger a build. This is done in your Profile page. To be extra cautious, just grant the token permission to
Run Build
for the project you're interested in. - Create a WebHook Parameter in your Project called something like
triggerToken
, so that you can pass this to the webhook.
- Create a WebHook to trigger on
Responsibility Changed
and choose your new template. Set the URL to be the teamcity server with/app/rest/buildQueue
.
- Set the webhook to fire on just the build you want.
- Set the webhook to use bearer authentication, add the
${triggerToken}
and create a Parameter formyBuildTypeId
. We need to create this because the template need to know which build to trigger. This the ID of the build, and is usually in the URL of the build.
Ignore the filter. I was trying to only trigger on a user interaction, but I have not got that filter working yet.
- Mark your Tests as fixed, and the build should be triggered. You should see it executing in the history page.
BTW, the notification is a different mechanism to the one I am able to use. It's the same events, but they have slightly different names. In the notifier it's called Investigation is Updated
, but in tcWebHooks it's called Responsibility Changed
because that is the name of the event hook I listen for.
I have also added hooks for Test muting on my local branch (not pushed yet) and my callback is called However it doesn't do anything yet. There is quite a lot more work to create a new event and add it to all the templates/rest api/UI/configuration code so I don't have it working yet.
Support for tests muted/unmuted added and released as version 1.2.2
https://github.com/tcplugins/tcWebHooks/releases/tag/v1.2.2