fp-wiki>ImportUser (Imported from MoinMoin) |
m (1 revision(s)) |
||
(No difference)
|
Latest revision as of 16:35, 24 May 2008
Automating Bugzilla
WWW::Bugzilla
This works, after a fashion. For some things, this module is broken (e.g. bug states doesn't include the additions RH has to bug states), for other bits, there are workarounds.
The main issue is that "goto bug#" form RH has at the top of just about every BZ page. WWW::Bugzilla isn't expecting this, and so tries to submit new/updates via that form, vs the second (proper) form on the page. bz.rh.com doesn't like this very much, for understandable reasons.
The workaround is to set the form name of the underlying WWW::Mechanize directly, before calling commit, e.g.,
$bug->{mech}->form_name('Create'); $bug->commit; #... $bug->{mech}->form_name('changeform'); $bug->commit;
SOAP / XMLRPC
While this seems to be a matter of some sort of "dark secret", there are a number of useful calls that can be made via bugzilla's XML-RPC interface. This page will talk about the known methods, and give examples in perl. Examples in other scripting languages are also welcome :)
Connecting via XML-RPC
Easy enough, using the perl module XMLRPC::Lite:
my $proxy = XMLRPC::Lite->proxy('https://bugzilla.redhat.com/bugzilla/xmlrpc.cgi');
You can access the interface by using the above proxy, a la:
my $soapres = $proxy->call( 'bugzilla.addComment', # method name 'perl-Net-CUPS', # bug # or alias $comment, # text for the comment 'me@someplace.com', # userid 'difficult' # password );
However, it's likely I'll be using this enough to wrap it in a Bugzilla::RedHat module or somesuch.
addComment
method name:: bugzilla.addComment
parameters:: bug # or alias
text of the comment
userid
password
optional parameters:: isprivate (flag) (?)
timestamp (?)
worktime (?)
returns:: people emailed, people not emailed
createBug
method name:: bugzilla.createBug
parameters:: bug fields
userid
password
optional parameters:: none
returns:: bug #
"bug fields" parameter
Data is passed to this method as a reference to a hash of key/value pairs. Known keys are listed below, unknown keys appear to be ignored:
product:: e.g. 'Fedora Extras' component:: e.g. 'perl-Foo' dependson:: bugs that block this bug version:: component version, e.g., 'fc6', 'devel' op_sys:: 'Linux', rep_platform:: platform this impacts, typically 'All' bug_severity:: e.g. 'normal', priority:: e.g. 'normal' short_desc:: the summary, e.g. "Won't complile with latest rawhide" comment:: a longer, initial comment bug_file_loc:: the "url" field alias:: an alias for the bug cc:: email addresses to cc assigned_to:: person the bug is assigned to
Usage
my %bug_values = ( product => $test ? 'Bugzilla' : 'Fedora Extras', component => $test ? 'test' : 'Package Review', depends_on => $test ? '' : $opts{dependson}, version => 'devel', op_sys => 'Linux', rep_platform => 'All', bug_severity => 'normal', priority => 'normal', short_desc => $summary, comment => $comment, bug_file_loc => $rpm->url, alias => $rpm->name, ); exists $opts{dependson} && ($bug_values{dependson} = $opts{dependson}); <!--# create a bug: %bug_values --> my $soapres = $proxy->call('bugzilla.createBug', \%bug_values, $ini{bugzilla}{userid}, $ini{bugzilla}{password} ); die_on_fault($soapres); my $res = $soapres->result; my $bug_num = shift @$res;