Bugzilla Automation with perl — add, update or query any bug in Bugzilla using perl and www series modules for perl.

2010-04-11 3 min read Fedora Linux

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 &#8221;python-bugzilla.noarch&#8221;. 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 = &#8221;https://x.x/bt/query.cgi?GoAheadAndLogIn=1&#8221;;

my $login = &#8221;x\@gx.com&#8221;;

my $pass = &#8221;xx&#8221;;

my $mech = WWW::Mechanize->new();

$mech->agent_alias( &#8217;Windows IE 6&#8217; );

$mech->get( $link );

my %login = ( &#8221;Bugzilla_login&#8221;=> $login,

&#8221;Bugzilla_password&#8221;=> $pass);

$mech->set_fields(%login);

$mech->click( &#8217;GoAheadAndLogIn&#8217; );

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 &#8221;perl-WWW-Bugzilla.noarch&#8221;. 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 &#8221;perl-Fedora-Bugzilla&#8221;, which is more useful for the Fedora Bugzilla. This also uses the XML-RPC interface and &#8221;Fedora&#8217;s Bugzilla implementation has a large number of custom methods.  This module aims to expose them, in a kinder, gentler way.&#8221; So, still no luck.

Let&#8217;s get back to basic&#8217;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 &#8221;$i&#8221; ;cat $i  |egrep &#8217;Summary|Product&#8217;| awk -F&#8217;;&#8217; '{printf &#8221;\t%s\t&#8221;,$2}&#8217;; 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&#8217;s for this to work.

Let&#8217;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.

comments powered by Disqus