开发者

Which perl module for creating/updating bugs on Bugzilla 4.0.1?

I have a large amount of bugs from Jira and Github that I want to transfer to Bugzilla. I can easily get the Jira bugs via xml and Github through the Net::Github API. The issue is with creating the bugs on Bugzilla. I have the login information 100% correct, but the bugs won't commit.

I am using the module found at http://search.cpan.org/~bmc/WWW-Bugzilla-1.5/WWW/Bugzilla.pm

I've noticed there are some other Bugzilla modules such as WWW::Bugzilla3 which I assume is version 3.0开发者_JS百科.0 of Bugzilla. Am I using the wrong one for Bugzilla 4.0.1?

If I simply create a Bugzilla object with just the server, email, and password, the object appears to be logging in correctly, but it can't get any of the products, components, or versions afterwards.

EDIT: I decided to try the Bugzilla3 module and it worked.


Solution was to use the Bugzilla3 module, but not all of its features work 100% with Bugzilla 4.0.1... It also lacks the ability to update submitted bugs, so we just moved all of the bugs to a new component, deleted that component, and ran the script again to compensate.


I've answered something that may be helpful for another SO question: How to use bugzilla API in existing bugzilla code? AND for a google groups one that I found: https://groups.google.com/forum/#!topic/mozilla.support.bugzilla/7KEs5HqUtgo

Both sources are about UPDATING an existing bug, but I found if you look through the bug.pm file of the Bugzilla source, you should be able to find some examples of how to create a new bug - I can see that you had problems with UPDATING, but were able to create the bugs using the BZ3 module.


Here's an excerpt from a a svn_bz_append.pl script (http://www.telegraphics.com.au/svn/svn_bz/trunk/) that I've modified that I use to update bugzilla comments on svn commits. Note that I have this script running on the same machine as the Bugzilla install, as it uses modules from within the Bugzilla directory. I have this working for Bugzilla v 4.2.3.

I've omitted quite a bit of this script to pull out the excerpt below:

use strict;
use warnings;

use Bugzilla;
use Bugzilla::Config;
use Bugzilla::Bug;

use Data::Dumper;

... create/fetch the userid and some bug Ids to work on ...

eg:

my $userid = 1;
my @bugs = ( 1, 2, 3 );
my $message = 'Say something here';

... now loop through the bug ids and add the comment...

foreach my $bugId (@bugs) {

my $user = new Bugzilla::User({ id => $userid}) 
 || ThrowUserError('invalid_username', { id => $userid}); #get the user from bugzilla
print STDERR 'user: '. Dumper($user); #pretty prints the user object

Bugzilla->set_user($user); #this authenticates the user so that you may perform actions on bugs that the user has permissions to.

my $bug = Bugzilla::Bug->check($bugId); #gets the bug
print STDERR 'bug: '. Dumper($bug); #pretty prints the bug object

$bug->add_comment($message); #adds a comment to the bug
$bug->update(); #updated the bug - don't forget to do this!
}

Please note that the Dumper functions are just using the excellent Data::Dumper module: http://perldoc.perl.org/Data/Dumper.html - you don't need them except for debugging.

The log in info came from: How can I authenticate when using the Bugzilla Perl API in a script?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜