Bugzilla Automation with perl — add, update or query any bug in Bugzilla using perl and www series modules for perl.
Today I was trying to do some queries and see if I could create a new bug or update a existing bug in the Bugzilla. The one that I was trying to access was on version 2.0 and not on 3.0. This being the case, the XMLRPC interface was not working properly and to top it all, I was wanted to query quite a lot of bugs. So, I went out to evaluate how to avoid the manual work and get this done faster. Here’s some of my findings:
Note: If you have direct access to the bugzilla database, dont bother with any of these, simplest is to directly query the database 🙂
There is a Bugzilla client for windows called <a href="http://www.softpedia.com/downloadTag/Bugzilla+client" target="_blank">MyZilla. This is a freeware, but I ran into problems running this with wine and did not bother to debug the same.
There is a python plugin to use bugzilla. The package name in Fedora for the same is ”python-bugzilla.noarch”. You can install this with
sudo yum install python-bugzilla.noarch
This uses the XML-RPC interface to talk to the bugzilla. So not of much use for me. But this is quite powerful tool. The man page for the tool is available <a href="https://fedorahosted.org/python-bugzilla/wiki/BugzillaManPage" target="_blank">here.
Lets try perl now to do what we want to. Let take a simple example using the perl mechanize module (taken from <a href="http://www.cpanforum.com/posts/4747" target="_blank">here):
#!/usr/bin/perl
use WWW::Mechanize;
my $link = ”https://x.x/bt/query.cgi?GoAheadAndLogIn=1”;
my $login = ”x\@gx.com”;
my $pass = ”xx”;
my $mech = WWW::Mechanize->new();
$mech->agent_alias( ’Windows IE 6’ );
$mech->get( $link );
my %login = ( ”Bugzilla_login”=> $login,
”Bugzilla_password”=> $pass);
$mech->set_fields(%login);
$mech->click( ’GoAheadAndLogIn’ );
Now, thats a pretty neat script. That will allow me to login to the Bugzilla account. But I still need to do some investigation and spend some time to execute my query and get the result. Haaaaaaaaa.. Am I the first one to think about this. NO. There is a perl module ”perl-WWW-Bugzilla.noarch”. This module provides some funtionality to add and update the bugs in bugzilla. If you look at the pm files for the module you will get enough hint to enter a new bug or update an existing bug. You can install this with :
sudo yum install perl-WWW-Bugzilla.noarch
There is a module ”perl-Fedora-Bugzilla”, which is more useful for the Fedora Bugzilla. This also uses the XML-RPC interface and ”Fedora’s Bugzilla implementation has a large number of custom methods. This module aims to expose them, in a kinder, gentler way.” So, still no luck.
Let’s get back to basic’s before we go any further. Lets try to do it with wget and shell and perl scripts.
Lets create a file with the list of bugs (each in seperate line) and call it list. And then execute the following:
for i in `cat list`; do wget http://1.1.1.2/bugzilla/long_list.cgi?buglist=$i -O $i -o temp; echo -n ”$i” ;cat $i |egrep ’Summary|Product’| awk -F’;’ '{printf ”\t%s\t”,$2}’; echo ;done
This will print the result neatly as
Bug ID Product Headline
and also save all the details of the bugs in individual files with Bug ID as the file name. Quite near, but need more to do for the execution of query. I still need the bug id’s for this to work.
Let’s now try to use a perl script with shell script called buglist. The script and readme are available <a href="https://bluequartz.org/svn/5100R/tags/raq550_OSS_1_0/ui/devel-tools/scripts/bugzilla/" target="_blank">here. The readme and the scripts are quite descriptive and you need to do minimal amount of chages to make this work. So finally I settled with this one with the changes required for my work. Hope this helps you when you are stuck with something in Bugzilla.
Related Articles:
- 2009/09/26 Script to generate a html file with link to all files in directory
- 2010/04/11 bash script to change vim colorscheme based on the available themes
- 2010/04/07 wine-doors – door to wine with applications like photoshop and lots of windows games.
- 2010/04/07 Adding date to Photographs.
- 2010/04/07 My project in sourceforge.net gnomedesktopwal
Authored By Amit Agarwal
Amit Agarwal, Linux and Photography are my hobbies.Creative Commons Attribution 4.0 International License.