From 29001170e197ac922e88da8552e5247cf8ad9911 Mon Sep 17 00:00:00 2001 From: "Jonathan \"Duke\" Leto" Date: Wed, 23 Feb 2011 00:25:30 +0000 Subject: Turn off debug statements by default --- lib/jitterbug/Builder.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/jitterbug/Builder.pm b/lib/jitterbug/Builder.pm index deb4c5b..f6fb41e 100644 --- a/lib/jitterbug/Builder.pm +++ b/lib/jitterbug/Builder.pm @@ -15,7 +15,7 @@ use jitterbug::Schema; #use Data::Dumper; local $| = 1; -use constant DEBUG => 1; +use constant DEBUG => 0; sub new { my $self = bless {} => shift; -- cgit 1.4.1 From 54fc972d56cd5d3b290e2618ff05f433ac05f8dd Mon Sep 17 00:00:00 2001 From: "Jonathan \"Duke\" Leto" Date: Wed, 23 Feb 2011 15:15:45 -0800 Subject: Add on_failure_to_email and on_pass_to_email config keys These keys can be used to override where pass/fail emails go. If they are defined, emails are sent to the specified email. If not, they go to the commit author. This feature is sponsored by IRC insultbots and the letters B, A, C, E and K. No bits where harmed in the making of this feature. --- config.yml | 2 ++ lib/jitterbug/Emailer.pm | 4 +++- t/005_builder.t | 2 ++ t/data/test.yml | 2 ++ 4 files changed, 9 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/config.yml b/config.yml index cb1e111..47f4f42 100644 --- a/config.yml +++ b/config.yml @@ -19,12 +19,14 @@ jitterbug: builder: ./scripts/capsule.sh builder_variables: on_failure: ./scripts/build-failed.sh + on_failure_to_email: on_failure_cc_email: alice@example.com on_failure_from_email: donotreply@example.com on_failure_subject_prefix: "[jitterbug] FAIL " on_failure_header: on_failure_footer: on_pass: ./scripts/build-pass.sh + on_pass_to_email: on_pass_cc_email: alice@example.com on_pass_subject_prefix: "[jitterbug] PASS " on_pass_from_email: donotreply@example.com diff --git a/lib/jitterbug/Emailer.pm b/lib/jitterbug/Emailer.pm index 0d4d7da..d43b120 100644 --- a/lib/jitterbug/Emailer.pm +++ b/lib/jitterbug/Emailer.pm @@ -42,7 +42,6 @@ sub run { 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_${status}_header"}; my $footer = $buildconf->{"on_${status}_footer"}; @@ -60,6 +59,9 @@ sub run { my ($short_message) = split /\n/, $message; + # Default to the to_email specified in our config. If it isn't set, + # use the author email + my $email = $buildconf->{"on_${status}_to_email"} || $desc->{'author'}{'email'}; my $stuff = Email::Stuff->from($buildconf->{"on_${status}_from_email"}) # bug in Email::Stuff brakes chaining if $email is empty diff --git a/t/005_builder.t b/t/005_builder.t index 93aa4c7..3adf39f 100644 --- a/t/005_builder.t +++ b/t/005_builder.t @@ -64,10 +64,12 @@ jitterbug::Test->init(); 'on_pass_header' => undef, 'on_failure_subject_prefix' => '[jitterbug] FAIL ', 'on_failure_from_email' => 'donotreply@example.com', + 'on_failure_to_email' => 'bob@example.com', 'on_failure_footer' => undef, 'on_failure_header' => undef, 'on_pass_footer' => undef, 'on_pass_cc_email' => 'alice@example.com', + 'on_pass_to_email' => undef, 'on_pass_from_email' => 'donotreply@example.com', 'on_failure_cc_email' => 'alice@example.com', 'on_pass' => './scripts/build-pass.sh', diff --git a/t/data/test.yml b/t/data/test.yml index 897b734..d8d21c0 100644 --- a/t/data/test.yml +++ b/t/data/test.yml @@ -19,12 +19,14 @@ jitterbug: builder: ./scripts/capsule.sh builder_variables: STUFF=BLAH on_failure: ./scripts/build-failed.sh + on_failure_to_email: bob@example.com on_failure_cc_email: alice@example.com on_failure_from_email: donotreply@example.com on_failure_subject_prefix: "[jitterbug] FAIL " on_failure_header: on_failure_footer: on_pass: ./scripts/build-pass.sh + on_pass_to_email: on_pass_cc_email: alice@example.com on_pass_subject_prefix: "[jitterbug] PASS " on_pass_from_email: donotreply@example.com -- cgit 1.4.1 From fcbcff656199a42e9966ddaf84c9e89291d2a3f3 Mon Sep 17 00:00:00 2001 From: "Jonathan \"Duke\" Leto" Date: Thu, 21 Apr 2011 12:44:36 -0400 Subject: Allow the config file to specify per-project builder and builder_variables, which override the global values --- lib/jitterbug/Builder.pm | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) (limited to 'lib') diff --git a/lib/jitterbug/Builder.pm b/lib/jitterbug/Builder.pm index f6fb41e..461945c 100644 --- a/lib/jitterbug/Builder.pm +++ b/lib/jitterbug/Builder.pm @@ -81,25 +81,27 @@ sub sleep { } sub run_task { - my $self = shift; - my ($task) = @_; - my $desc = JSON::decode_json( $task->commit->content ); - my $conf = $self->{'conf'}; + my ($self,$task) = @_; + + my $desc = JSON::decode_json( $task->commit->content ); + my $conf = $self->{'conf'}; + my $project = $task->project; my $dt = DateTime->now(); $task->update({started_when => $dt}); $desc->{'build'}{'start_time'} = $dt->epoch; debug("Build Start"); + my $report_path = dir( $conf->{'jitterbug'}{'reports'}{'dir'}, - $task->project->name, + $project->name, $task->commit->sha256, ); my $build_dir = dir( $conf->{'jitterbug'}{'build'}{'dir'}, - $task->project->name, + $project->name, ); debug("Removing $build_dir"); @@ -114,7 +116,8 @@ sub run_task { debug("Checking out " . $task->commit->sha256 . " from $repo into $build_dir\n"); $r->run( 'checkout', $task->commit->sha256 ); - my $builder = $conf->{'jitterbug'}{'build_process'}{'builder'}; + my $builder = $conf->{'jitterbug'}{'projects'}{$project->name}{'builder'} + || $conf->{'jitterbug'}{'build_process'}{'builder'}; my $perlbrew = $conf->{'jitterbug'}{'options'}{'perlbrew'}; my $email_on_pass = $conf->{'jitterbug'}{'options'}{'email_on_pass'}; @@ -122,7 +125,9 @@ sub run_task { debug("email_on_pass = $email_on_pass"); debug("perlbrew = $perlbrew"); - my $builder_variables = $conf->{'jitterbug'}{'build_process'}{'builder_variables'}; + # If the project has custom builder variables, use those. Otherwise, use the global setting + my $builder_variables = $conf->{'jitterbug'}{'projects'}{$project->name}{'builder_variables'} + || $conf->{'jitterbug'}{'build_process'}{'builder_variables'}; my $builder_command = "$builder_variables $builder $build_dir $report_path $perlbrew"; -- cgit 1.4.1