Popular Posts

Monday, June 15, 2009

Deadline Email Notifications using Bugzilla Whining Feature

Bugzilla is a great project. Yet, customizing it to your needs is an overwhelming task!

I was assigned a task that our Bugzilla server should automatically notify the task assignees upon the deadline. After a lot of search and reading, here is what I reached at...

First, since our ISP did block our Sendmail server, we needed another way to send emails from Bugzilla... and this post saved my life:

http://www.dawood.in/bugzilla_alerts_using_gmail.html



The perl module Email::Send::SMTP::TLS was installed using the CPAN command:

perl -MCPAN -e 'install Email::Send::SMTP::TLS'

Then, from the administration, the email service was set to SMTP::TLS as per the instructions in the previous link.

Finally, the bugzilla code was modified as per the instructions, as follows

/usr/share/perl5/Bugzilla/Mailer.pm



if ($method eq "SMTP" || $method eq "SMTP::TLS") {

my $smtp_server;

my $smtp_port;

($smtp_server,$smtp_port) = split /:/,Bugzilla->params->{"smtpserver"};

push @args, Host => $smtp_server,

#username => Bugzilla->params->{"smtp_username"},

User => Bugzilla->params->{"smtp_username"},

#password => Bugzilla->params->{"smtp_password"},

Password => Bugzilla->params->{"smtp_password"},

Hello => $hostname,

Debug => Bugzilla->params->{'smtp_debug'};

push @args, Port => $smtp_port if($smtp_port);

}




Now I have a Bugzilla system that can send emails... well, what about automated notifications? The whining feature came into play...

The whining feature was used to automatically notify the users about deadlines. The was inspired by the instructions in the following links (instructions of Marc):

http://markmail.org/message/2y67gfpa2ocu7ewa

http://groups.google.com/group/mozilla.support.bugzilla/browse_thread/thread/87159cba2d617553



The whining feature relies on Saved Searches. A 'saved search' is to be created and the search should be done for every member of a group. To execute the saved search for everybody, a group should be created that contains all the users of Bugzilla. This could be done by using the user RegExp '.*'.

Then, the Save Search 'Tasks due soon' was created. It searches all the products for bugs that are open (NEW, ASSIGNED, REOPENED). Then the advanced search (boolean charts) was used to search for only the bugs for which the current user is assigned (Assignee 'is equal to' '%user%') or cc'ed (CC 'is equal to' '%user%'). This was done using the bugzilla Pronoun Substitution feature (http://www.bugzilla.org/docs/2.20/html/query.html). In addition, the bug should have its deadline due soon or overdue (Deadline 'is less than' '+3d'). The final saved search looks like this:


Finally, from the Whining feature in administration, all the pieces were put together as follows:

In sum, the saved search entitled 'Tasks due soon' should be run 'Each day' 'at 15:00' for every member of the group 'everybody' and the search results should be sent 'one message per bug' to the '%user%'.

One question may arise, since we are running the search for all the users, how did we guarantee that the email will be sent to the bug assignee only and not to everybody? This was done using the Pronoun Substitution feature of Bugzilla. Basically, '%user%' is being automatically substituted for by the current user for which the search is done. So, if the current user is not the assignee or on the CC of the bug, there will be no search results, and consequently, there will be no emails sent!



We are not done yet! One final thing needs to be done. Add the whine.pl to your hourly cron, so that cron would automatically run the whine.pl script and Bugzilla start whining. This was done by adding a script 'bugzilla3' under '/etc/cron.hourly/' on a Debian Lenny system. The script was adopted from the 'bugzilla3' script under '/etc/cron.daily/'. Its code is:



#!/bin/sh



set -e



umask 022



doit()

{

if [ -f /usr/share/bugzilla3/lib/whine.pl ] ; then

su www-data -c /usr/share/bugzilla3/lib/whine.pl

fi

}



# process the main configuration: /etc/bugzilla3

doit



exit 0



That is all!

4 comments:

Formal resignation letter said...

At last you have won the batter and configured the server! Thanks for sharing the screen shots with us..very helpful

smplcv said...

Seems your a programing geek! The work was superb!


CV Examples

cv said...

Perfect article to read. Have bookmarked and please updating..thanks dude


CV Templates

John Alert said...

Great Article
Machine Learning Projects for Students
Final Year Project Centers in Chennai