Self-Introduction: Roger Lipp and a ruby command-line tool for bugzilla
Lipp, Roger D (Mission Critical Linux)
roger.lipp at hp.com
Tue Oct 2 20:49:43 UTC 2012
> -----Original Message-----
> From: Frédéric Buclin [mailto:lpsolit at gmail.com]
> Sent: Tuesday, October 02, 2012 11:47 AM
> To: developers at bugzilla.org
> Cc: Lipp, Roger D (Mission Critical Linux)
> Subject: Re: Self-Introduction: Roger Lipp and a ruby command-line tool for bugzilla
> Le 01. 10. 12 06:46, Lipp, Roger D (Mission Critical Linux) a écrit :
> > I would love to contribute my work to bugzilla, perhaps as a "ruby
> > example of using the webservices api", or as a command-line interface
> > that works behind a corporate firewall.
> > Is this of interest?
> Hello Roger,
> All contributions are always welcome, but why choosing Ruby rather than
> Perl as the whole Bugzilla application is written in Perl? :)
> Is your CLI running on the server-side or client-side? This part is a
> bit unclear to me.
This script runs on the client side. Ruby was a nice choice because of the ability to easily deal with different encodings (XML, YAML, JSON). By using ruby I don't have a lot of clutter in the code to handle these issues.
To give you a better idea of what I'm doing, here is the help output from my script:
$ rbugz --help
Usage: rbugz [options] [bugid]
-h, --help Display this screen
-v, --verbose Output more information
--version Display version information. rbugz 0.2
--server=SERVER Select which bugzilla server to interact with. Defaults defined in /opt/rbugz/etc/servers.yaml
-x, --xml display results in XML format (default is YAML)
-j, --json display results in JSON format (default is YAML)
-i, --include=FIELDLIST a comma-separated list of fields to include in the output
-l, --login login to bugzilla. Your login cookie will be stored in ~/.bugzilla-cookies.
-u, --user=USER bugzilla user name
-p, --password=PASSWORD bugzilla password. Omit this option to be prompted for your password
Defect Lookup Options:
-a, --all display all available information about the bug
-t, --attachments display only attachments associated with bug
-c, --comments display only comments associated with bug
-s, --history display history of changes for the bug
-q, --query=FILENAME specify a YAML file that contains the query paramenter. STDIN may be passed as the filename
The fun stuff is in the query option. It turns out that the combination of YAML and xmlrpc is a pretty natural fit. The query file can contain things like:
creator: roger.lipp at hp.com
status: [ASSIGNED, OPEN]
Ruby's yaml library will read that in and generate a hash, which can then be handed directly to the xmlrpc call.
All in all, I think this provides a good working example of how to use the WebServices API on the client side.
More information about the developers