Generating RT bugs out of CPAN Testers’ Reports

Posted in: Technical Track

A few hours ago, I received a CPAN Testers‘s report. The report was a genuine bug (CPANtesters++. Love you guys), and as I made my way to to create a ticket to track the issue, I found myself thinking that it’d be nice to have a ‘bug this‘ button straight from the smoke report page.

You all know where that kind of thinking leads to, right?

I didn’t GreaseMonkey’ed a button into the CPAN Testers page (yet), but I did the second-best thing. Namely, a little command-line script that takes a report url and uses it to auto-generate a bug report to the right distribution:

$ ./

The script is pretty straight-forward. It grabs the bug report off the CPAN Testers site, figures out which distribution we’re talking about, generates an email with the report information, gives you a chance to edit the report (the first line is the bug’s title, the rest will be its description) and sends the email on its merry way to

In a future iteration, I’ll probably switch to using the REST interface to RT, but for now the email interface is proving to be Good Enoughtm.

#!/usr/bin/env perl

use strict;
use warnings;

use URI;
use URI::QueryParam;
use LWP::Simple qw/ get /;
use File::Temp qw/ tempfile /;
use Email::Sender::Simple qw(sendmail);
use Email::Simple;
use Email::Simple::Creator;
use HTML::TreeBuilder::XPath;
use autodie;

my $from = '';

my $url = URI->new( shift || die );

# we just want the report
$url->query_param( raw => 1 );

my $report = HTML::TreeBuilder::XPath->new;
$report->parse( get $url );

# which distribution?
( my $dist = $report->findvalue('/html/head/title') ) =~

$dist or die;

my ( $fh, $filename ) = tempfile();

# Link to html version of the report
# for the ticket description
$url->query_param( raw => 0 );

print {$fh} join "\n", "CPAN Tester Failure\n", $url,

system $ENV{EDITOR}, $filename;

open $fh, '<', $filename;

chomp( my $subject = <$fh> );

print "sending email... ";

        header => [
            To      => "bug-$dist\",
            From    => $from,
            Subject => $subject,

        body => do { local $/ = <$fh> },
    ) );

print "done\n";

Interested in working with Yanick? Schedule a tech call.

No comments

Leave a Reply

Your email address will not be published. Required fields are marked *