From 3a866b1da6674ccad19a1283eda492b3eebfd474 Mon Sep 17 00:00:00 2001 From: franck cuny Date: Mon, 27 Sep 2010 21:21:25 +0200 Subject: move build script to conf --- config.yml | 3 +++ scripts/builder.pl | 34 +++++++++++++++++++--------------- scripts/capsule.sh | 3 +++ 3 files changed, 25 insertions(+), 15 deletions(-) diff --git a/config.yml b/config.yml index 06fbeac..75ce73a 100644 --- a/config.yml +++ b/config.yml @@ -16,3 +16,6 @@ jitterbug: dir: /tmp/jitterbug build: dir: /tmp/build + build_process: + builder: ./scripts/capsule.sh + on_failure: ./scripts/on_failure.sh diff --git a/scripts/builder.pl b/scripts/builder.pl index ae32056..e8fa87d 100644 --- a/scripts/builder.pl +++ b/scripts/builder.pl @@ -13,18 +13,18 @@ use Git::Repository; $|++; -my $conf = LoadFile('config.yml'); -my $redis = Redis->new(server => $conf->{redis}); -my $key = join(':', 'jitterbug', 'tasks'); +my $conf = LoadFile('config.yml'); +my $redis = Redis->new( server => $conf->{redis} ); +my $key = join( ':', 'jitterbug', 'tasks' ); while (1) { my $task_key = $redis->spop($key); if ($task_key) { - my $task = $redis->get($task_key); - my $desc = JSON::decode_json($task); - my $repo = $desc->{repo} . '.git'; - my $commit = delete $desc->{id}; - my $project = delete $desc->{project}; + my $task = $redis->get($task_key); + my $desc = JSON::decode_json($task); + my $repo = $desc->{repo} . '.git'; + my $commit = delete $desc->{id}; + my $project = delete $desc->{project}; my $report_path = File::Spec->catdir( $conf->{jitterbug}->{reports}->{dir}, @@ -34,19 +34,20 @@ while (1) { File::Spec->catdir( $conf->{jitterbug}->{build}->{dir}, $project ); my $r = Git::Repository->create( clone => $repo => $build_dir ); - $r->run('checkout', $commit); + $r->run( 'checkout', $commit ); - my $res = `./scripts/capsule.sh $build_dir $report_path`; + my $builder = $conf->{jitterbug}->{build_process}->{builder}; + my $res = `$builder $build_dir $report_path`; rmtree($build_dir); $redis->del($task_key); my $build = { - project => $project, - repo => $repo, - commit => $commit, - time => time(), + project => $project, + repo => $repo, + commit => $commit, + time => time(), %$desc, }; @@ -63,12 +64,15 @@ while (1) { my ( $name, ) = basename($version); $name =~ s/\.txt//; if ( $result !~ /PASS/ ) { + # mail author of the commit my $message = $desc->{message}; my $commiter = $desc->{author}->{email}; my $output = "Build failed"; my $sha = $desc->{commit}; - `./scripts/build-failed $commiter $message $output $sha`; + my $on_failure = + $conf->{jitterbug}->{build_process}->{on_failure}; + `$on_failure $commiter $message $output $sha`; } $build->{version}->{$name} = $result; close $fh; diff --git a/scripts/capsule.sh b/scripts/capsule.sh index 0535529..a5fc076 100755 --- a/scripts/capsule.sh +++ b/scripts/capsule.sh @@ -1,5 +1,8 @@ #!/bin/bash +# first arg: build_dir +# second arg: report path + set -e builddir=$1 -- cgit 1.4.1