summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHéctor Orón Martínez <hector.oron@collabora.co.uk>2016-02-08 18:50:17 (GMT)
committerHéctor Orón Martínez <hector.oron@collabora.co.uk>2016-02-08 18:50:17 (GMT)
commite3b3ad26effa2ce870ade2af97ef34e74720c4e6 (patch)
tree482c83daaf777de9d949a3ab9f3de70248dc9b65
parent34ba805007acb1d929fe4df3cd9425d6f1de6c9a (diff)
downloadopen-build-service-e3b3ad26effa2ce870ade2af97ef34e74720c4e6.tar.gz
open-build-service-e3b3ad26effa2ce870ade2af97ef34e74720c4e6.tar.xz
add phab hooks
Signed-off-by: Héctor Orón Martínez <hector.oron@collabora.co.uk>
-rw-r--r--src/backend/BSConfig.pm.template15
-rwxr-xr-xsrc/backend/bs_sched52
2 files changed, 55 insertions, 12 deletions
diff --git a/src/backend/BSConfig.pm.template b/src/backend/BSConfig.pm.template
index a8e4872..3128a24 100644
--- a/src/backend/BSConfig.pm.template
+++ b/src/backend/BSConfig.pm.template
@@ -93,13 +93,26 @@ our $enable_download_on_demand = 1;
# When a bugprefix is mapped in, system qa-bughandler is invoked reading the
# configuration file at /etc/qa-bughandler/$bzconfig
our $enable_bugzilla_hooks = 0;
-#our $bugzilla_prefix = {
+#our $bug_prefix = {
# "exampledistro:examplesuite:examplecomponent/examplerepository" => {
# "bzprefix" => "BUG",
# "bzconfig" => "bug",
# },
#};
+# To enable phabricator hooks, which update tickets when builds are successful.
+# 0 .. hook disabled
+# 1 .. hook enabled
+# When a bugprefix is mapped in, system pqa is invoked reading the
+# configuration file at /etc/arc/$bzconfig
+our $enable_phab_hooks = 0;
+#our $bug_prefix = {
+# "exampledistro:examplesuite:examplecomponent/examplerepository" => {
+# "phabprefix" => "BUG",
+# "pqaconfig" => "bug",
+# },
+#};
+
# Disable fdatasync calls, increases the speed, but may lead to data
# corruption on system crash when the filesystem does not guarantees
# data write before rename.
diff --git a/src/backend/bs_sched b/src/backend/bs_sched
index 3b75ec0..2bd847f 100755
--- a/src/backend/bs_sched
+++ b/src/backend/bs_sched
@@ -117,6 +117,15 @@ sub update_bugzilla {
system(@args)
}
+sub update_phab {
+ my ($bugid, $packid, $myarch, $project, $repo, $pqaconfig) = @_;
+ print "Updating phabricator....";
+ my $comment = "This ticket update was triggered by a successful $project build on $myarch for $repo.\n";
+ $comment .= "Once this package build has been integrated into an image, it will be automatically updated again.";
+ my @args = ("pqa", "--config", "/etc/arc/$pqaconfig", "update", "--field", "std:maniphest:apertis:package=$packid", "--comment", $comment, "--status", "fixsubmitted", $bugid);
+ system(@args)
+}
+
sub unify {
my %h = map {$_ => 1} @_;
@@ -2671,13 +2680,14 @@ sub jobfinished {
addjobhist($prp, $info, $status, $js, 'succeeded');
writexml("$statusdir/.status", "$statusdir/status", $status, $BSXML::buildstatus);
- while( my ($k, $v) = each %$BSConfig::bugzilla_prefix ) {
+ while( my ($k, $v) = each %$BSConfig::bug_prefix ) {
if ($prp =~ /^$k/) {
# Find the latest version built
# To extract a changelog:
# dpkg-deb --fsys-tarfile package.deb | tar -O -xvf - ./usr/share/doc/$packid/changelog.Debian.gz | gunzip | dpkg-parsechangelog -l-
local *D;
- my @bugs;
+ my @bzbugs;
+ my @phabbugs;
opendir(D, "$reporoot/$prp/$myarch/$packid/");
my $packageName = "";
my $packageVersion = "";
@@ -2691,7 +2701,8 @@ sub jobfinished {
chomp;
print $_."\n";
if ($inChanges) {
- push @bugs, /#(\d+)/g if /$v->{'bzprefix'}: *(.*)/;
+ push @bzbugs, /#(\d+)/g if /$v->{'bzprefix'}: *(.*)/;
+ push @phabbugs, /T(\d+)/g if /$v->{'phabprefix'}: *(.*)/;
} else {
my ($tag, $value) = split(':', $_);
chomp $value;
@@ -2710,16 +2721,35 @@ sub jobfinished {
}
}
closedir D;
- print "Found bugs: ";
- print Dumper(@bugs);
-
- # Remove duplicates
- my %bughash = map { $_, 1 } @bugs;
- @bugs = keys %bughash;
# Update bugzilla
- foreach (@bugs) {
- update_bugzilla($_, $packageName.'-'.$packageVersion, $myarch, $projid, $repoid, $v->{'bzconfig'})
+ if ($BSConfig::enable_bugzilla_hooks > 0) {
+
+ print "Found BugZilla bugs: ";
+ print Dumper(@bzbugs);
+
+ # Remove duplicates
+ my %bughash = map { $_, 1 } @bzbugs;
+ @bzbugs = keys %bughash;
+
+ foreach (@bzbugs) {
+ update_bugzilla($_, $packageName.'-'.$packageVersion, $myarch, $projid, $repoid, $v->{'bzconfig'})
+ }
+ }
+
+ # Update phabricator
+ if ($BSConfig::enable_phabricator_hooks > 0) {
+
+ print "Found Phabricator bugs: ";
+ print Dumper(@phabbugs);
+
+ # Remove duplicates
+ my %bughash = map { $_, 1 } @phabbugs;
+ @phabbugs = keys %bughash;
+
+ foreach (@phabbugs) {
+ update_phab($_, $packageName.'-'.$packageVersion, $myarch, $projid, $repoid, $v->{'pqaconfig'})
+ }
}
}
}