2012-04-26 109 views
1

那么,目前我有两个目标。如何在现有的bugzilla代码中使用bugzilla API?

  1. 用户没有在bugzilla中编辑错误权限,但他/她应该在该错误上编写/发表评论。我认为这可以通过以下API来实现,但我不确定,因为我是bugzilla和Perl中的新成员。 http://www.bugzilla.org/docs/tip/en/html/api/Bugzilla/WebService/Bug.html#add_comment

  1. 我想通过使用importxml.pl导入错误,但我不想在DB新的条目。我只是想在bug.xml文件的基础上修改一些bugzilla的bug,这些bug包含bug信息。

    即perl的-TC:\ Bugzilla的\ Bugzilla的\ importxml.pl -v C:\ Bugzilla的\ Bugzilla的\ mybugs \ bug.xml

可能是下面的API可能是有益的,但我不是当然。

http://www.bugzilla.org/docs/tip/en/html/api/Bugzilla/WebService/Bug.html#update


那么,什么是可能的方式来实现这些目标?

正如我在想,可能是我应该使用这些API的方法到现有Bugzilla的代码和我的梦想是:

  1. 意见会为没有bug的编辑权限谁的用户启用。
  2. 我将通过传递一些参数来从命令行运行importxml.pl脚本,并修改现有错误的一些字段。

但我不确定,无论我是对还是错。我也不知道如何使用这些API的方法?

回答

0

我可以与第一点帮助:

下面是我已经修改了我使用SVN提交更新的Bugzilla注释的一个svn_bz_append.pl脚本(http://www.telegraphics.com.au/svn/svn_bz/trunk/)的摘录。请注意,我将这个脚本与Bugzilla安装在同一台机器上运行,因为它使用了Bugzilla目录中的模块。我对Bugzilla v 4.2.3有效。

我省略了相当多的此脚本的拉出摘录如下:

use strict; 
use warnings; 

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

use Data::Dumper; 

...创建/获取用户名和一些bug IDS对工作...

例如:

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

...现在通过错误号环路,并添加评论...

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! 

}

请注意,自卸车功能只是用出色的数据::自卸车模块:http://perldoc.perl.org/Data/Dumper.html - 你不需要他们除了调试。

登录信息来自:How can I authenticate when using the Bugzilla Perl API in a script?