parautenbach / TeamCity-HipChat-Notifier

TeamCity HipChat Notifier for sending build server notifications to HipChat.
Other
59 stars 31 forks source link

Filtering notifications by branch #38

Open ma499 opened 9 years ago

ma499 commented 9 years ago

We use a feature-branching workflow with Git and TeamCity runs CI on all (auto-discovered) active branches. Is there any way that we can filter notifications so that, for example, we only get notifications for the master branch of any project?

parautenbach commented 9 years ago

That's an interesting use case I haven't thought of before, thank you.

I could add a filter mechanism (based on a regex, for example). Currently, besides the global configuration, there is also per project configurations. It seems like such filter functionality would make most sense on the project level. Would you like to set this filter per project, or rather per build configuration?

ma499 commented 9 years ago

Hi, @parautenbach, yes we'd definitely prefer to be able to configure this per project / build configuration setting but a global setting only (or as as a default) would still be be useful, I think. Thanks for picking this up.

parautenbach commented 9 years ago

I think I will implement this as a global setting and a per project setting, but not per build configuration. Is there perhaps a scenario you can think of to set it per build configuration, rather than on the project level? My thinking is that setting this per build configuration may become cumbersome.

parautenbach commented 9 years ago

I'm still working through the options, but currently I'm inclined towards only the global setting, because one could set up a (albeit complex) regex that can be used globally to exclude certain branches.

Then, I also now realise, that the filter can be set up as an inclusive or exclusive filter. I may add a setting for selecting that too. Reading your initial post, it looks like you want a positive inclusion, rather than an exclusion. Please correct me where I'm misunderstanding.

ma499 commented 9 years ago

I'll think it through and discuss with my team members then get back to you.

parautenbach commented 9 years ago

Great!

parautenbach commented 9 years ago

Now available in v0.8.0, just released.

jesuissur commented 9 years ago

It would have been interesting to have this setting per hipchat tab (TC project). What would you think?

Thanks Phil

Update

What we would like to have in fact is to be able to set multiple Rooms settings for one TeamCity's project. And each one of those setting would have a room name and a branch filter.

parautenbach commented 9 years ago

Hi Phil

Yes, you will see above that I wanted to first implement this at a global level, as I myself don't use the branch filtering on my own setup, so I didn't want to implement this in full, given just one opinion (i.e. the OP's, not mine). The intention was always to extend this as needed or useful to others.

The current implementation basically satisfies the original post here, which is to filter so that only master branches trigger notifications. I've made the implicit assumption that one can, with albeit a complex regex, set one regex across all projects for all types of conventions that people may use.

If I understand you correctly, you may also find #23 interesting.

I'm in general also conscious about creating a configuration nightmare. I think per project configuration of the branch filtering is more feasible than per build configuration. There is already a project tab for the configuration of the plugin. Is it there where you would like to see the branch configuration too, as well as the ability to specify multiple rooms?

jesuissur commented 9 years ago

Hi Pieter

Per project configuration was exactly what I meant. If you want some help for this feature, let us know.

Thanks Phil

parautenbach commented 9 years ago

Hi Phil

Please pardon the delay.

Contributions are more than welcome. I will be spending more time on this soon too.

Besides #23, #18 is also related to this, so we will have to see where we can find some common ground.

ma499 commented 9 years ago

Hi @parautenbach the regexp branch filter doesn't seem to work.

We're using git and I've tried the following filter expressions: refs/heads/master master ^master$

In all cases, we still get notified about every branch. I had a look through the code but can't see any obvious reason why it shouldn't work. Can you advise?

parautenbach commented 9 years ago

Did it work before and now stopped working, or didn't it ever work for you?

Could you post the relevant section of your log (starting with the event up to the point where the message is sent), and also your config (with your API credentials removed)?

You can also try to replicate your config in the test testBuildStartedBranchFilterMatch in HipChatServerExtensionTest.java to try and replicate the issue if you don't want to or can't provide the information above.

ghostal commented 8 years ago

I'm also experiencing problems with this feature, although I'm seeing the opposite of what @ma499 is seeing - when including a regex in the global config, nothing gets reported to HipChat. When I remove the regex filter, events are reported to HipChat. Values I have tried master and (.*)master(.*), expecting that to match the project's master branch.

I'm using TeamCity 9.1.3 and HipChatNotifier 0.9.2.

I'd be happy to provide logs, although I struggled to follow the directions you linked to @parautenbach - I couldn't find a conf/ directory or a teamcity-server-log4j.xml. Where would these reside? I can use those instructions to switch on the HipChat Notifier debug logging on my production TC server, right?