Merge pull request #643 from input-output-hk/github-plugin-short-context-debug

allow using a shorter context and increase hydra-notify debug
This commit is contained in:
Graham Christensen 2019-03-20 14:23:31 -05:00 committed by GitHub
commit 2c142868a0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
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};
break;
};
printMsg(lvlChatty, "Executing hydra-notify " + concatStringsSep(" ", argv));
execvp("hydra-notify", (char * *) stringsToCharPtrs(argv).data()); // FIXME: remove cast
throw SysError("cannot start hydra-notify");
});

View file

@ -32,17 +32,22 @@ 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) : ();
@ -59,7 +64,9 @@ 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 POSTing to '", $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}));