From e0f9ce9218fe3151fe6e395038bcd088dbafad2a Mon Sep 17 00:00:00 2001 From: "Jonathan \"Duke\" Leto" Date: Sat, 8 Jan 2011 01:44:59 -0800 Subject: Add ability to disable perlbrew This option comes in handy for those that want to run long test suites on just one version of Perl and/or those using local::lib (which doesn't play nice with perlbrew with XS modules). --- lib/jitterbug/Builder.pm | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/jitterbug/Builder.pm b/lib/jitterbug/Builder.pm index 72b4216..6441c0d 100644 --- a/lib/jitterbug/Builder.pm +++ b/lib/jitterbug/Builder.pm @@ -113,7 +113,9 @@ sub run_task { my $builder = $conf->{'jitterbug'}{'build_process'}{'builder'}; - my $builder_command = "$builder $build_dir $report_path"; + my $perlbrew = $conf->{'options'}{'perlbrew'} || 1; + + my $builder_command = "$builder $build_dir $report_path $perlbrew"; debug("Going to run builder : $builder_command"); my $res = `$builder_command`; -- cgit v1.2.3 From b1a5bddc4c42308942d007ad71654f4bf4c0f282 Mon Sep 17 00:00:00 2001 From: "Jonathan \"Duke\" Leto" Date: Mon, 10 Jan 2011 14:08:27 -0800 Subject: Add the ability to CC an email when builds fail --- lib/jitterbug/Builder.pm | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/jitterbug/Builder.pm b/lib/jitterbug/Builder.pm index 6441c0d..0d24620 100644 --- a/lib/jitterbug/Builder.pm +++ b/lib/jitterbug/Builder.pm @@ -142,7 +142,9 @@ sub run_task { my $sha = $desc->{'id'}; my $on_failure = $conf->{'jitterbug'}{'build_process'}{'on_failure'}; - my $failure_cmd = "$on_failure $commiter $message $output $sha"; + my $on_failure_email = + $conf->{'jitterbug'}{'build_process'}{'on_failure_email'}; + my $failure_cmd = "$on_failure $commiter $message $output $sha $on_failure_email"; debug("Running failure command: $failure_cmd"); `$failure_cmd`; } -- cgit v1.2.3 From 0f24016d696f5a7fbac7de7e7712c8e26278bc8f Mon Sep 17 00:00:00 2001 From: "Jonathan \"Duke\" Leto" Date: Tue, 11 Jan 2011 10:47:35 -0800 Subject: Attempt to fix the mangled build failure email bug --- lib/jitterbug/Builder.pm | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'lib') diff --git a/lib/jitterbug/Builder.pm b/lib/jitterbug/Builder.pm index 0d24620..58da724 100644 --- a/lib/jitterbug/Builder.pm +++ b/lib/jitterbug/Builder.pm @@ -136,15 +136,15 @@ sub run_task { if ( !$result || ($result && $result !~ /PASS/ )) { # mail author of the commit $result = "FAIL"; - my $message = $desc->{'message'}; - my $commiter = $desc->{'author'}{'email'}; - my $output = "Build failed"; - my $sha = $desc->{'id'}; - my $on_failure = - $conf->{'jitterbug'}{'build_process'}{'on_failure'}; - my $on_failure_email = - $conf->{'jitterbug'}{'build_process'}{'on_failure_email'}; - my $failure_cmd = "$on_failure $commiter $message $output $sha $on_failure_email"; + my $message = $desc->{'message'}; + my $commiter = $desc->{'author'}{'email'}; + my $output = "Build failed"; + my $sha = $desc->{'id'}; + my $on_failure = $conf->{'jitterbug'}{'build_process'}{'on_failure'}; + my $on_failure_email = $conf->{'jitterbug'}{'build_process'}{'on_failure_email'}; + + $message =~ s/'/\\'/g; $commiter =~ s/'/\\'/g; $output =~ s/'/\\'/g; + my $failure_cmd = qq{$on_failure '$commiter' '$message' '$output' $sha $on_failure_email}; debug("Running failure command: $failure_cmd"); `$failure_cmd`; } -- cgit v1.2.3 From 490c240d5f70ca5c7fabd747ec6bfb7e218eeef7 Mon Sep 17 00:00:00 2001 From: "Jonathan \"Duke\" Leto" Date: Tue, 11 Jan 2011 15:38:50 -0500 Subject: Make build failure email more useful by including TAP output --- lib/jitterbug/Builder.pm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/jitterbug/Builder.pm b/lib/jitterbug/Builder.pm index 58da724..376b98c 100644 --- a/lib/jitterbug/Builder.pm +++ b/lib/jitterbug/Builder.pm @@ -138,13 +138,13 @@ sub run_task { $result = "FAIL"; my $message = $desc->{'message'}; my $commiter = $desc->{'author'}{'email'}; - my $output = "Build failed"; + my $output = $lines; my $sha = $desc->{'id'}; my $on_failure = $conf->{'jitterbug'}{'build_process'}{'on_failure'}; my $on_failure_email = $conf->{'jitterbug'}{'build_process'}{'on_failure_email'}; $message =~ s/'/\\'/g; $commiter =~ s/'/\\'/g; $output =~ s/'/\\'/g; - my $failure_cmd = qq{$on_failure '$commiter' '$message' '$output' $sha $on_failure_email}; + my $failure_cmd = sprintf("%s '%s' %s '%s' '%s' %s %s", $on_failure, $commiter, $task->project->name, $message, $output, $sha, $on_failure_email); debug("Running failure command: $failure_cmd"); `$failure_cmd`; } -- cgit v1.2.3 From b3a31c9d5ac670a7e04602bb8e7e4e3018535e35 Mon Sep 17 00:00:00 2001 From: "Jonathan \"Duke\" Leto" Date: Tue, 11 Jan 2011 16:39:51 -0500 Subject: Make failure email more customizable, start new jitterbug::Emailer in perl --- lib/jitterbug/Builder.pm | 4 ++-- lib/jitterbug/Emailer.pm | 43 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+), 2 deletions(-) create mode 100644 lib/jitterbug/Emailer.pm (limited to 'lib') diff --git a/lib/jitterbug/Builder.pm b/lib/jitterbug/Builder.pm index 376b98c..4a8451f 100644 --- a/lib/jitterbug/Builder.pm +++ b/lib/jitterbug/Builder.pm @@ -141,10 +141,10 @@ sub run_task { my $output = $lines; my $sha = $desc->{'id'}; my $on_failure = $conf->{'jitterbug'}{'build_process'}{'on_failure'}; - my $on_failure_email = $conf->{'jitterbug'}{'build_process'}{'on_failure_email'}; + my $on_failure_cc_email = $conf->{'jitterbug'}{'build_process'}{'on_failure_email'}; $message =~ s/'/\\'/g; $commiter =~ s/'/\\'/g; $output =~ s/'/\\'/g; - my $failure_cmd = sprintf("%s '%s' %s '%s' '%s' %s %s", $on_failure, $commiter, $task->project->name, $message, $output, $sha, $on_failure_email); + my $failure_cmd = sprintf("%s '%s' %s '%s' '%s' %s %s", $on_failure, $commiter, $task->project->name, $message, $output, $sha, $on_failure_cc_email); debug("Running failure command: $failure_cmd"); `$failure_cmd`; } diff --git a/lib/jitterbug/Emailer.pm b/lib/jitterbug/Emailer.pm new file mode 100644 index 0000000..97ec640 --- /dev/null +++ b/lib/jitterbug/Emailer.pm @@ -0,0 +1,43 @@ +package jitterbug::Emailer; + +use strict; +use warnings; +use Email::Stuff; + +sub new { + my $self = bless {} => shift; + my ($conf,$task,$tap_output) = @_; + # smelly + $self->{'conf'} = $conf; + $self->{'task'} = $task; + $self->{'tap_output'} = $tap_output; + + return $self; +} + +sub run { + my $self = shift; + my $buildconf = $conf->{'jitterbug'}{'build_process'}; + my $project = $task->project->name; + + my $sha1 = $task->commit->sha256; + my $body = <from($buildconf->{'on_failure_from_email') + ->to($buildconf->{'on_failure_to_email'}) + ->cc($buildconf->{'on_failure_cc_email'}) + ->text_body($body) + ->subject( + $buildconf->{'on_failure_subject_prefix'} . "$project @ $sha1" + ) + # Should we attach a build log for convenience? + # ->attach(io('dead_bunbun_faked.gif')->all, + # filename => 'dead_bunbun_proof.gif') + ->send; + + return $self; +} + +1; -- cgit v1.2.3 From 4bb424bf9937a0dc7b29cda40657631607ffdeaa Mon Sep 17 00:00:00 2001 From: "Jonathan \"Duke\" Leto" Date: Wed, 12 Jan 2011 11:46:49 -0500 Subject: Add some tests for jitterbug::Emailer --- lib/jitterbug/Emailer.pm | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/jitterbug/Emailer.pm b/lib/jitterbug/Emailer.pm index 97ec640..95bda0d 100644 --- a/lib/jitterbug/Emailer.pm +++ b/lib/jitterbug/Emailer.pm @@ -17,15 +17,17 @@ sub new { sub run { my $self = shift; - my $buildconf = $conf->{'jitterbug'}{'build_process'}; + my $task = $self->{'task'}; + my $buildconf = $self->{'conf'}->{'jitterbug'}{'build_process'}; my $project = $task->project->name; + my $tap_output = $self->{'tap_output'}; my $sha1 = $task->commit->sha256; my $body = <from($buildconf->{'on_failure_from_email') + Email::Stuff->from($buildconf->{'on_failure_from_email'}) ->to($buildconf->{'on_failure_to_email'}) ->cc($buildconf->{'on_failure_cc_email'}) ->text_body($body) -- cgit v1.2.3 From c16d34fa7b67ad1e5db7a098e74c5f711e222403 Mon Sep 17 00:00:00 2001 From: "Jonathan \"Duke\" Leto" Date: Wed, 12 Jan 2011 13:31:51 -0500 Subject: Fix some bugs in jitterbug::Emailer and add mocked test data --- lib/jitterbug/Emailer.pm | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/jitterbug/Emailer.pm b/lib/jitterbug/Emailer.pm index 95bda0d..648c72f 100644 --- a/lib/jitterbug/Emailer.pm +++ b/lib/jitterbug/Emailer.pm @@ -21,14 +21,16 @@ sub run { my $buildconf = $self->{'conf'}->{'jitterbug'}{'build_process'}; my $project = $task->project->name; my $tap_output = $self->{'tap_output'}; - my $sha1 = $task->commit->sha256; + my $desc = JSON::decode_json( $task->commit->content ); + my $email = $desc->{'author'}{'email'}; + my $body = <from($buildconf->{'on_failure_from_email'}) - ->to($buildconf->{'on_failure_to_email'}) + ->to($email) ->cc($buildconf->{'on_failure_cc_email'}) ->text_body($body) ->subject( -- cgit v1.2.3 From b2fe2456e476962c19cceb74b1d17fb0f22c3c3e Mon Sep 17 00:00:00 2001 From: "Jonathan \"Duke\" Leto" Date: Wed, 12 Jan 2011 10:56:48 -0800 Subject: More tests for jitterbug::Emailer --- lib/jitterbug/Emailer.pm | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) (limited to 'lib') diff --git a/lib/jitterbug/Emailer.pm b/lib/jitterbug/Emailer.pm index 648c72f..4bf2e51 100644 --- a/lib/jitterbug/Emailer.pm +++ b/lib/jitterbug/Emailer.pm @@ -3,6 +3,7 @@ package jitterbug::Emailer; use strict; use warnings; use Email::Stuff; +use JSON; sub new { my $self = bless {} => shift; @@ -16,30 +17,33 @@ sub new { } sub run { - my $self = shift; - my $task = $self->{'task'}; - my $buildconf = $self->{'conf'}->{'jitterbug'}{'build_process'}; - my $project = $task->project->name; + my $self = shift; + my $task = $self->{'task'}; + my $buildconf = $self->{'conf'}->{'jitterbug'}{'build_process'}; + my $project = $task->project->name; my $tap_output = $self->{'tap_output'}; - my $sha1 = $task->commit->sha256; - my $desc = JSON::decode_json( $task->commit->content ); - my $email = $desc->{'author'}{'email'}; + my $sha1 = $task->commit->sha256; + my $desc = JSON::decode_json( $task->commit->content ); + my $email = $desc->{'author'}{'email'}; my $body = <from($buildconf->{'on_failure_from_email'}) - ->to($email) + my $stuff = Email::Stuff->from($buildconf->{'on_failure_from_email'}) + # bug in Email::Stuff brakes chaining if $email is empty + ->to($email || " ") ->cc($buildconf->{'on_failure_cc_email'}) ->text_body($body) ->subject( $buildconf->{'on_failure_subject_prefix'} . "$project @ $sha1" - ) + ); # Should we attach a build log for convenience? # ->attach(io('dead_bunbun_faked.gif')->all, # filename => 'dead_bunbun_proof.gif') - ->send; + $self->{'last_email_sent'} = $stuff; + + $stuff->send; return $self; } -- cgit v1.2.3 From 94b70f3c91af81008a450d15b382c93705da2ce5 Mon Sep 17 00:00:00 2001 From: "Jonathan \"Duke\" Leto" Date: Wed, 12 Jan 2011 15:56:31 -0800 Subject: Allow specification of a perl module to handle build failure emails --- lib/jitterbug/Builder.pm | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/jitterbug/Builder.pm b/lib/jitterbug/Builder.pm index 4a8451f..297861f 100644 --- a/lib/jitterbug/Builder.pm +++ b/lib/jitterbug/Builder.pm @@ -146,7 +146,14 @@ sub run_task { $message =~ s/'/\\'/g; $commiter =~ s/'/\\'/g; $output =~ s/'/\\'/g; my $failure_cmd = sprintf("%s '%s' %s '%s' '%s' %s %s", $on_failure, $commiter, $task->project->name, $message, $output, $sha, $on_failure_cc_email); debug("Running failure command: $failure_cmd"); - `$failure_cmd`; + + # does it look like a module name? + if ($on_failure =~ /::/) { + # we should do some error checking here + $on_failure->new($conf,$task,$output)->run; + } else { + system($failure_cmd); + } } $desc->{'build'}{'version'}{$name} = $result; close $fh; -- cgit v1.2.3 From af6972d660d074f2971636c3b7384b7a75928fe7 Mon Sep 17 00:00:00 2001 From: "Jonathan \"Duke\" Leto" Date: Wed, 12 Jan 2011 16:02:00 -0800 Subject: Allow a header and footer for failure emails to be specified --- lib/jitterbug/Emailer.pm | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'lib') diff --git a/lib/jitterbug/Emailer.pm b/lib/jitterbug/Emailer.pm index 4bf2e51..2af7590 100644 --- a/lib/jitterbug/Emailer.pm +++ b/lib/jitterbug/Emailer.pm @@ -25,9 +25,15 @@ sub run { my $sha1 = $task->commit->sha256; my $desc = JSON::decode_json( $task->commit->content ); my $email = $desc->{'author'}{'email'}; + my $header = $buildconf->{'on_failure_header'}; + my $footer = $buildconf->{'on_failure_footer'}; my $body = <from($buildconf->{'on_failure_from_email'}) -- cgit v1.2.3 From a7d36c2ecb88a9a25488e53f7e30385b626ff569 Mon Sep 17 00:00:00 2001 From: "Jonathan \"Duke\" Leto" Date: Thu, 13 Jan 2011 18:00:12 -0500 Subject: Load the on_failure class at runtime before instantiating it --- lib/jitterbug/Builder.pm | 1 + 1 file changed, 1 insertion(+) (limited to 'lib') diff --git a/lib/jitterbug/Builder.pm b/lib/jitterbug/Builder.pm index 297861f..a836f70 100644 --- a/lib/jitterbug/Builder.pm +++ b/lib/jitterbug/Builder.pm @@ -150,6 +150,7 @@ sub run_task { # does it look like a module name? if ($on_failure =~ /::/) { # we should do some error checking here + eval "require $on_failure"; $on_failure->new($conf,$task,$output)->run; } else { system($failure_cmd); -- cgit v1.2.3 From 26df149efd3b962dafa3ccd9e6c1f1f54734477c Mon Sep 17 00:00:00 2001 From: "Jonathan \"Duke\" Leto" Date: Thu, 13 Jan 2011 18:10:12 -0500 Subject: Put commit message in subject of failure emails and improve body format --- lib/jitterbug/Emailer.pm | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/jitterbug/Emailer.pm b/lib/jitterbug/Emailer.pm index 2af7590..3c40bfd 100644 --- a/lib/jitterbug/Emailer.pm +++ b/lib/jitterbug/Emailer.pm @@ -23,14 +23,20 @@ sub run { my $project = $task->project->name; my $tap_output = $self->{'tap_output'}; my $sha1 = $task->commit->sha256; + my $shortsha1 = substr($sha1, 0, 8); my $desc = JSON::decode_json( $task->commit->content ); my $email = $desc->{'author'}{'email'}; + my $message = $desc->{'message'}; my $header = $buildconf->{'on_failure_header'}; my $footer = $buildconf->{'on_failure_footer'}; my $body = <cc($buildconf->{'on_failure_cc_email'}) ->text_body($body) ->subject( - $buildconf->{'on_failure_subject_prefix'} . "$project @ $sha1" + $buildconf->{'on_failure_subject_prefix'} . "$project @ $shortsha1 $message" ); # Should we attach a build log for convenience? # ->attach(io('dead_bunbun_faked.gif')->all, -- cgit v1.2.3 From 99ed391c7d50437b103ef018168a97e577698458 Mon Sep 17 00:00:00 2001 From: "Jonathan \"Duke\" Leto" Date: Thu, 13 Jan 2011 18:55:48 -0500 Subject: Allow placeholders for project name and SHA1 in build failure emails --- lib/jitterbug/Emailer.pm | 3 +++ 1 file changed, 3 insertions(+) (limited to 'lib') diff --git a/lib/jitterbug/Emailer.pm b/lib/jitterbug/Emailer.pm index 3c40bfd..ab9bedb 100644 --- a/lib/jitterbug/Emailer.pm +++ b/lib/jitterbug/Emailer.pm @@ -41,6 +41,9 @@ $tap_output $footer BODY + # Expand placeholders in our on_failure header and footer + $body =~ s/%%PROJECT%%/$project/g; + $body =~ s/%%SHA1%%/$sha1/g; my $stuff = Email::Stuff->from($buildconf->{'on_failure_from_email'}) # bug in Email::Stuff brakes chaining if $email is empty -- cgit v1.2.3 From dddeaba05015d4040ab1aeb502a81e291e9c56a4 Mon Sep 17 00:00:00 2001 From: "Jonathan \"Duke\" Leto" Date: Tue, 18 Jan 2011 15:30:02 -0500 Subject: Refactor jitterbug::Emailer to get rid of some warnings and improve tests --- lib/jitterbug/Emailer.pm | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) (limited to 'lib') diff --git a/lib/jitterbug/Emailer.pm b/lib/jitterbug/Emailer.pm index ab9bedb..60837d6 100644 --- a/lib/jitterbug/Emailer.pm +++ b/lib/jitterbug/Emailer.pm @@ -16,12 +16,29 @@ sub new { return $self; } +sub _make_body { + my ($header, $message, $tap, $footer) = @_; + + no warnings 'uninitialized'; + return <{'task'}; my $buildconf = $self->{'conf'}->{'jitterbug'}{'build_process'}; my $project = $task->project->name; - my $tap_output = $self->{'tap_output'}; + my $tap = $self->{'tap_output'}; my $sha1 = $task->commit->sha256; my $shortsha1 = substr($sha1, 0, 8); my $desc = JSON::decode_json( $task->commit->content ); @@ -29,18 +46,8 @@ sub run { my $message = $desc->{'message'}; my $header = $buildconf->{'on_failure_header'}; my $footer = $buildconf->{'on_failure_footer'}; + my $body = _make_body($header,$message, $tap, $footer); - my $body = < Date: Tue, 18 Jan 2011 17:34:41 -0500 Subject: Add ability to use test failure summary in failure email template --- lib/jitterbug/Emailer.pm | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'lib') diff --git a/lib/jitterbug/Emailer.pm b/lib/jitterbug/Emailer.pm index 60837d6..7a8ed9e 100644 --- a/lib/jitterbug/Emailer.pm +++ b/lib/jitterbug/Emailer.pm @@ -22,13 +22,11 @@ sub _make_body { no warnings 'uninitialized'; return <{'on_failure_header'}; my $footer = $buildconf->{'on_failure_footer'}; my $body = _make_body($header,$message, $tap, $footer); + my $summary; - # Expand placeholders in our on_failure header and footer + if ( $tap =~ m/^(Test Summary Report.*)/ms ) { + $summary = $1; + } + + # Expand placeholders in our failure email $body =~ s/%%PROJECT%%/$project/g; $body =~ s/%%SHA1%%/$sha1/g; + $body =~ s/%%SUMMARY%%/$summary/g; + my $stuff = Email::Stuff->from($buildconf->{'on_failure_from_email'}) # bug in Email::Stuff brakes chaining if $email is empty -- cgit v1.2.3 From bf58f6037d4d50dbe602926d8be0ade10bdd522a Mon Sep 17 00:00:00 2001 From: "Jonathan \"Duke\" Leto" Date: Tue, 18 Jan 2011 17:50:16 -0500 Subject: Get rid of uninitialized warning in the test suite --- lib/jitterbug/Emailer.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/jitterbug/Emailer.pm b/lib/jitterbug/Emailer.pm index 7a8ed9e..d21028f 100644 --- a/lib/jitterbug/Emailer.pm +++ b/lib/jitterbug/Emailer.pm @@ -45,7 +45,7 @@ sub run { my $header = $buildconf->{'on_failure_header'}; my $footer = $buildconf->{'on_failure_footer'}; my $body = _make_body($header,$message, $tap, $footer); - my $summary; + my $summary = ''; if ( $tap =~ m/^(Test Summary Report.*)/ms ) { $summary = $1; -- cgit v1.2.3