allow using a shorter context and increase hydra-notify debug

This commit is contained in:
Michael Bishop
2018-09-10 13:50:24 -03:00
parent 186137ee11
commit 1c76ad3936
2 changed files with 14 additions and 3 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};
break;
};
printMsg(lvlChatty, "hydra-notify " + concatStringsSep(" ", argv));
execvp("hydra-notify", (char * *) stringsToCharPtrs(argv).data()); // FIXME: remove cast
throw SysError("cannot start hydra-notify");
});

View File

@@ -31,23 +31,30 @@ sub common {
my $ua = LWP::UserAgent->new();
foreach my $conf (@config) {
print STDERR "GithubStatus_Debug job name $jobName\n";
next unless $jobName =~ /^$conf->{jobs}$/;
# Don't send out "pending" status updates if the build is already finished
next if !$finished && $b->finished == 1;
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(
{
state => $finished ? toGithubState($b->buildstatus) : "pending",
target_url => "$baseurl/build/" . $b->id,
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 = defined $inputs_cfg ? ref $inputs_cfg eq "ARRAY" ? @$inputs_cfg : ($inputs_cfg) : ();
my %seen = map { $_ => {} } @inputs;
while (my $eval = $evals->next) {
print STDERR "GithubStatus_Debug eval $eval\n";
foreach my $input (@inputs) {
print STDERR "GithubStatus_Debug input $input\n";
my $i = $eval->jobsetevalinputs->find({ name => $input, altnr => 0 });
next unless defined $i;
my $uri = $i->uri;
@@ -58,13 +65,16 @@ sub common {
$uri =~ m![:/]([^/]+)/([^/]+?)(?:.git)?$!;
my $owner = $1;
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 ", $url, "\n";
my $req = HTTP::Request->new('POST', $url);
$req->header('Content-Type' => 'application/json');
$req->header('Accept' => 'application/vnd.github.v3+json');
$req->header('Authorization' => ($self->{config}->{github_authorization}->{$owner} // $conf->{authorization}));
$req->content($body);
my $res = $ua->request($req);
print STDERR $res->status_line, ": ", $res->decoded_content, "\n" unless $res->is_success;
print STDERR "GithubStatus_Debug ", $res->status_line, ": ", $res->decoded_content, "\n";
print STDERR "GithubStatus_Error ", $res->status_line, ": ", $res->decoded_content, "\n" unless $res->is_success;
}
}
}