From 3ad091faf35c36c56cf5a8e7e397ad5a50a6341a Mon Sep 17 00:00:00 2001 From: Michael Bishop Date: Mon, 10 Sep 2018 13:50:24 -0300 Subject: [PATCH] allow using a shorter context and increase hydra-notify debug (cherry picked from commit 1c76ad393669af2f728fd519a050f417319412a6) --- src/hydra-queue-runner/hydra-queue-runner.cc | 1 + src/lib/Hydra/Plugin/GithubStatus.pm | 11 +++++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/hydra-queue-runner/hydra-queue-runner.cc b/src/hydra-queue-runner/hydra-queue-runner.cc index 70329a9e..1c82cab3 100644 --- a/src/hydra-queue-runner/hydra-queue-runner.cc +++ b/src/hydra-queue-runner/hydra-queue-runner.cc @@ -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"); }); diff --git a/src/lib/Hydra/Plugin/GithubStatus.pm b/src/lib/Hydra/Plugin/GithubStatus.pm index a0ad3393..59b0dc06 100644 --- a/src/lib/Hydra/Plugin/GithubStatus.pm +++ b/src/lib/Hydra/Plugin/GithubStatus.pm @@ -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}));