【问题标题】:How to use bugzilla API in existing bugzilla code?如何在现有的 bugzilla 代码中使用 bugzilla API?
【发布时间】:2014-04-25 14:52:28
【问题描述】:

嗯,目前我有两个目标。

  1. 用户在 bugzilla 中没有编辑错误权限,但他/她应该在该错误上编写/发布 cmets。我认为这可以通过以下 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 现有错误的一些字段。

    即perl -T C:\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


那么,有哪些可能的方法来实现这些目标??

正如我所想,也许我应该在现有的 bugzilla 代码中使用这些 API 的方法,而我的梦想是:

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

但我不确定,我的想法是对还是错。我也不知道这些API的方法怎么用??

【问题讨论】:

    标签: perl bugzilla


    【解决方案1】:

    email_in.pl 脚本可以执行您所要求的类型的事情。但是,您需要创建一个有权进行更改的用户,并且您需要将数据转换为 email_in.pl 可以理解的形式。

    http://www.bugzilla.org/docs/4.2/en/html/api/email_in.html

    【讨论】:

      【解决方案2】:

      第一点我可以帮忙:

      这是我修改的 svn_bz_append.pl 脚本 (http://www.telegraphics.com.au/svn/svn_bz/trunk/) 的摘录,我用它来更新 svn 提交上的 bugzilla cmets。请注意,我在安装 Bugzilla 的同一台机器上运行此脚本,因为它使用 Bugzilla 目录中的模块。我有这个适用于 Bugzilla v 4.2.3。

      我已经省略了相当多的这个脚本来提取下面的摘录:

      use strict;
      use warnings;
      
      use Bugzilla;
      use Bugzilla::Config;
      use Bugzilla::Bug;
      
      use Data::Dumper;
      

      ...创建/获取用户 ID 和一些要处理的错误 ID ...

      例如:

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

      ...现在遍历错误 ID 并添加注释...

      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!
      

      }

      请注意,Dumper 函数只是使用了出色的 Data::Dumper 模块:http://perldoc.perl.org/Data/Dumper.html - 除了调试之外,您不需要它们。

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

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2014-02-23
        • 1970-01-01
        • 1970-01-01
        • 2023-03-18
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多