tcplugins / tcWebHooks

WebHooks plugin for Teamcity. Supports many build states and payload formats.
https://netwolfuk.wordpress.com/category/teamcity/tcplugins/tcwebhooks/
157 stars 30 forks source link

Key cache lookup by project id and unique id #240

Closed matt-richardson closed 5 months ago

matt-richardson commented 6 months ago

To avoid duplicates when projects are copied.

Fixes https://github.com/tcplugins/tcWebHooks/issues/238.

Note: I haven't tested this, as I'm struggling to compile locally. (I'm also not a java developer, so there's a lot of things that I dont know that I dont know :smile:).

netwolfuk commented 6 months ago

I thought there might be some other bit that needed work. I'll take a look later in the week.

image

netwolfuk commented 6 months ago

BTW, this should work (I am using Java 8). mvn test package

matt-richardson commented 6 months ago

From what I can tell - these are to do with test setup. I didn't get very far with debugging though.

netwolfuk commented 6 months ago

From what I can tell - these are to do with test setup. I didn't get very far with debugging though.

ah, ok. I'll pull the branch and run it up locally. Not sure when yet.

matt-richardson commented 6 months ago

Just pushed a change - I think it should pass the tests.

(When I run it locally, I get a bunch of test failures similar to java.lang.IllegalStateException: @NotNull method webhook/teamcity/settings/entity/WebHookTemplateEntity.getTemplateDescription must not return null. Not sure why it's doing that for me, and not you?)

netwolfuk commented 6 months ago

Yep, that's fixed all the core tests. Just the REST api ones failing now. But don't spend time on that, as I am in the middle of migrating all that code to rest-api-legacy project.

matt-richardson commented 6 months ago

I'm unblocked now - I manually modified the id's in the config, and after restarting teamcity, all the webhooks are showing up in the right place.

Now, it's only future project copies that I'm thinking about, but not expecting that to happen too soon, so no rush.

Good luck with the legacy fun :)

netwolfuk commented 6 months ago

I'm really sorry. I didn't realise you were blocked by this. D'oh!

matt-richardson commented 6 months ago

No stress - I was only "blocked" until I found how the code worked, and even then, it wasn't a biggie - if push came to shove, I could've edited the config directly.

netwolfuk commented 6 months ago

I thought I had implemented a partial work around where a "save" of the webhook forces a reload on that project's webhooks, but I still have the code here and it never made it into a release.

This would have allowed you to edit plugin-settings and then create a new webhook would would've fixed the ids in the cache map.

But now we know the actual reason for that issue, so that's a win :-)

netwolfuk commented 6 months ago

I have it compiled and running. Copying a project works, but does not refresh the cache. If I edit and save or create a new webhook, the the old webhooks that were copied over show up. However, the ID is the same and so items in the history will be misleading. Eg, if you click the right most icon in a history page, it will show two webhooks since they have the same ID.

I'll look further into the copy event that Pavel mentioned, and look to do a regenerate of the UniqueId on Project copy.

netwolfuk commented 5 months ago

Closing because this was done as part of #242 and #238