Search code examples
pythonbuildbotemail-notifications

Buildbot deactivate mail notifier for some schedulers (not for builders)


I have buildbot running with 2 builders. The first builder performs build steps, then triggers (via triggerable scheduler) the second builder which performs tests. There is 3 schedulers: SingleBranch, Force and try, which trigger 1st builder, also there is 2 mail notifiers:

for mode, builders in (('warnings', ['Build', 'Test']),
                   ('passing', ['Test'])):
   c['status'].append(MailNotifier(fromaddr='...',
                                   sendToInterestedUsers=True,
                                   extraRecipients=['...'],
                                   mode=mode,
                                   builders=builders,
                                   ))

So one notifier sends reports about fails for both Build and Test builders and another notifier sends reports about success only for Test builder(it means build was successful too). Currently mail notifier send reports for all three schedulers that activate Build builder. Question: is it possible to make notifiers work just for SingleBranch scheduler?

Thanks in advance.


Solution

  • There's no easy way to do this. However it is possible to do what you want:

    class MyMailNotifier(MailNotifier):
        def isMailNeeded(self, build, results):
            if build.properties.getProperty('scheduler') == '<SingleBranchSchedulerName>':
                return MailNotifier.isMailNeeded(self, build, results)
            else:
                return False
    

    While this code is not tested, I'm quite confident it does what you'd like.