allow using a shorter context and increase hydra-notify debug

(cherry picked from commit 1c76ad393669af2f728fd519a050f417319412a6)
This commit is contained in:
Michael Bishop 2018-09-10 13:50:24 -03:00 committed by Samuel Leathers
parent 8a41ea5f60
commit 3ad091faf3
No known key found for this signature in database
GPG key ID: 9BCE91C969768E0F
2 changed files with 10 additions and 2 deletions

View file

@ -487,6 +487,7 @@ void State::notificationSender()
argv = {"hydra-notify", "step-finished", std::to_string(item.id), std::to_string(item.stepNr), item.logPath}; argv = {"hydra-notify", "step-finished", std::to_string(item.id), std::to_string(item.stepNr), item.logPath};
break; break;
}; };
printMsg(lvlChatty, "Executing hydra-notify " + concatStringsSep(" ", argv));
execvp("hydra-notify", (char * *) stringsToCharPtrs(argv).data()); // FIXME: remove cast execvp("hydra-notify", (char * *) stringsToCharPtrs(argv).data()); // FIXME: remove cast
throw SysError("cannot start hydra-notify"); throw SysError("cannot start hydra-notify");
}); });

View file

@ -32,17 +32,22 @@ sub common {
my $ua = LWP::UserAgent->new(); my $ua = LWP::UserAgent->new();
foreach my $conf (@config) { foreach my $conf (@config) {
print STDERR "GithubStatus_Debug job name $jobName\n";
next unless $jobName =~ /^$conf->{jobs}$/; next unless $jobName =~ /^$conf->{jobs}$/;
# Don't send out "pending" status updates if the build is already finished # Don't send out "pending" status updates if the build is already finished
next if !$finished && $b->finished == 1; next if !$finished && $b->finished == 1;
my $contextTrailer = $conf->{excludeBuildFromContext} ? "" : (":" . $b->id); my $contextTrailer = $conf->{excludeBuildFromContext} ? "" : (":" . $b->id);
my $github_job_name = $jobName =~ s/-pr-\d+//r;
my $extendedContext = $conf->{context} // "continuous-integration/hydra:" . $jobName . $contextTrailer;
my $shortContext = $conf->{context} // "ci/hydra:" . $github_job_name . $contextTrailer;
my $context = $conf->{useShortContext} ? $shortContext : $extendedContext;
my $body = encode_json( my $body = encode_json(
{ {
state => $finished ? toGithubState($b->buildstatus) : "pending", state => $finished ? toGithubState($b->buildstatus) : "pending",
target_url => "$baseurl/build/" . $b->id, target_url => "$baseurl/build/" . $b->id,
description => $conf->{description} // "Hydra build #" . $b->id . " of $jobName", description => $conf->{description} // "Hydra build #" . $b->id . " of $jobName",
context => $conf->{context} // "continuous-integration/hydra:" . $jobName . $contextTrailer context => $context
}); });
my $inputs_cfg = $conf->{inputs}; my $inputs_cfg = $conf->{inputs};
my @inputs = defined $inputs_cfg ? ref $inputs_cfg eq "ARRAY" ? @$inputs_cfg : ($inputs_cfg) : (); my @inputs = defined $inputs_cfg ? ref $inputs_cfg eq "ARRAY" ? @$inputs_cfg : ($inputs_cfg) : ();
@ -59,7 +64,9 @@ sub common {
$uri =~ m![:/]([^/]+)/([^/]+?)(?:.git)?$!; $uri =~ m![:/]([^/]+)/([^/]+?)(?:.git)?$!;
my $owner = $1; my $owner = $1;
my $repo = $2; my $repo = $2;
my $req = HTTP::Request->new('POST', "https://api.github.com/repos/$owner/$repo/statuses/$rev"); my $url = "https://api.github.com/repos/$owner/$repo/statuses/$rev";
print STDERR "GithubStatus_Debug POSTing to '", $url, "'\n";
my $req = HTTP::Request->new('POST', $url);
$req->header('Content-Type' => 'application/json'); $req->header('Content-Type' => 'application/json');
$req->header('Accept' => 'application/vnd.github.v3+json'); $req->header('Accept' => 'application/vnd.github.v3+json');
$req->header('Authorization' => ($self->{config}->{github_authorization}->{$owner} // $conf->{authorization})); $req->header('Authorization' => ($self->{config}->{github_authorization}->{$owner} // $conf->{authorization}));