From 1cda08351fe23e914a9aeb04587e025b7fc687ed Mon Sep 17 00:00:00 2001 From: Graham Christensen Date: Fri, 20 Aug 2021 21:26:07 -0400 Subject: [PATCH 01/14] CatalystUtils: rename $b to $builds (perlcritic) --- src/lib/Hydra/Helper/CatalystUtils.pm | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/lib/Hydra/Helper/CatalystUtils.pm b/src/lib/Hydra/Helper/CatalystUtils.pm index 53ce53c4..cd3a0fd7 100644 --- a/src/lib/Hydra/Helper/CatalystUtils.pm +++ b/src/lib/Hydra/Helper/CatalystUtils.pm @@ -109,14 +109,14 @@ sub searchBuildsAndEvalsForJobset { { columns => ['id', 'job', 'finished', 'buildstatus'] } ); - foreach my $b (@allBuilds) { - my $jobName = $b->get_column('job'); + foreach my $build (@allBuilds) { + my $jobName = $build->get_column('job'); $evals->{$eval->id}->{timestamp} = $eval->timestamp; $evals->{$eval->id}->{builds}->{$jobName} = { - id => $b->id, - finished => $b->finished, - buildstatus => $b->buildstatus + id => $build->id, + finished => $build->finished, + buildstatus => $build->buildstatus }; $builds{$jobName} = 1; $nrBuilds++; From d0fb3cbf8f0fcc6776cd4c5f6dc2ab0199c2f312 Mon Sep 17 00:00:00 2001 From: Graham Christensen Date: Fri, 20 Aug 2021 21:26:50 -0400 Subject: [PATCH 02/14] Job: $b -> $build (perlcritic) --- src/lib/Hydra/Controller/Job.pm | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/lib/Hydra/Controller/Job.pm b/src/lib/Hydra/Controller/Job.pm index efaa508e..a9e65f76 100644 --- a/src/lib/Hydra/Controller/Job.pm +++ b/src/lib/Hydra/Controller/Job.pm @@ -121,10 +121,10 @@ sub overview : Chained('job') PathPart('') Args(0) { my $aggregates = {}; my %constituentJobs; - foreach my $b (@constituents) { - $aggregates->{$b->get_column('aggregate')}->{constituents}->{$b->job} = - { id => $b->id, finished => $b->finished, buildstatus => $b->buildstatus }; - $constituentJobs{$b->job} = 1; + foreach my $build (@constituents) { + $aggregates->{$build->get_column('aggregate')}->{constituents}->{$build->job} = + { id => $build->id, finished => $build->finished, buildstatus => $build->buildstatus }; + $constituentJobs{$build->job} = 1; } foreach my $agg (keys %$aggregates) { From b6714cdce3f36783932e2e1707ad5ccc65292cf0 Mon Sep 17 00:00:00 2001 From: Graham Christensen Date: Fri, 20 Aug 2021 21:28:09 -0400 Subject: [PATCH 03/14] JobsetEval: $a, $b to $left, $right (perlcritic) --- src/lib/Hydra/Controller/JobsetEval.pm | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/lib/Hydra/Controller/JobsetEval.pm b/src/lib/Hydra/Controller/JobsetEval.pm index ded2d05c..63a11dfa 100644 --- a/src/lib/Hydra/Controller/JobsetEval.pm +++ b/src/lib/Hydra/Controller/JobsetEval.pm @@ -64,9 +64,9 @@ sub view_GET { $c->stash->{otherEval} = $eval2 if defined $eval2; sub cmpBuilds { - my ($a, $b) = @_; - return $a->get_column('job') cmp $b->get_column('job') - || $a->get_column('system') cmp $b->get_column('system') + my ($left, $right) = @_; + return $left->get_column('job') cmp $right->get_column('job') + || $left->get_column('system') cmp $right->get_column('system') } my @builds = $eval->builds->search($filter, { columns => [@buildListColumns] }); From 0f88014631cd61c21095ef55bd1cfbc8f370ff30 Mon Sep 17 00:00:00 2001 From: Graham Christensen Date: Fri, 20 Aug 2021 21:33:32 -0400 Subject: [PATCH 04/14] CircleCiNotification: $b -> $build (perlcritic) --- src/lib/Hydra/Plugin/CircleCINotification.pm | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/lib/Hydra/Plugin/CircleCINotification.pm b/src/lib/Hydra/Plugin/CircleCINotification.pm index e9e8623d..398fe066 100644 --- a/src/lib/Hydra/Plugin/CircleCINotification.pm +++ b/src/lib/Hydra/Plugin/CircleCINotification.pm @@ -13,22 +13,22 @@ sub isEnabled { } sub buildFinished { - my ($self, $build, $dependents) = @_; + my ($self, $topbuild, $dependents) = @_; my $cfg = $self->{config}->{circleci}; my @config = defined $cfg ? ref $cfg eq "ARRAY" ? @$cfg : ($cfg) : (); # Figure out to which branches to send notification. my %branches; - foreach my $b ($build, @{$dependents}) { - my $prevBuild = getPreviousBuild($b); - my $jobName = showJobName $b; + foreach my $build ($topbuild, @{$dependents}) { + my $prevBuild = getPreviousBuild($build); + my $jobName = showJobName $build; foreach my $branch (@config) { my $force = $branch->{force}; next unless $jobName =~ /^$branch->{jobs}$/; # If build is failed, don't trigger circleci - next if ! $force && $b->buildstatus != 0; + next if ! $force && $build->buildstatus != 0; my $fullUrl = "https://circleci.com/api/v1.1/project/" . $branch->{vcstype} . "/" . $branch->{username} . "/" . $branch->{project} . "/tree/" . $branch->{branch} . "?circle-token=" . $branch->{token}; $branches{$fullUrl} = 1; From 0d4ce15c62fe760f929602c43ae122cdddf52bea Mon Sep 17 00:00:00 2001 From: Graham Christensen Date: Fri, 20 Aug 2021 21:35:18 -0400 Subject: [PATCH 05/14] EmailNotification: $build -> $topbuild, $b -> $build (perlcritic) --- src/lib/Hydra/Plugin/EmailNotification.pm | 44 +++++++++++------------ 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/src/lib/Hydra/Plugin/EmailNotification.pm b/src/lib/Hydra/Plugin/EmailNotification.pm index 33935069..4e6c7809 100644 --- a/src/lib/Hydra/Plugin/EmailNotification.pm +++ b/src/lib/Hydra/Plugin/EmailNotification.pm @@ -46,46 +46,46 @@ EOF sub buildFinished { - my ($self, $build, $dependents) = @_; + my ($self, $topbuild, $dependents) = @_; - die unless $build->finished; + die unless $topbuild->finished; # Figure out to whom to send notification for each build. For # each email address, we send one aggregate email listing only the # relevant builds for that address. my %addresses; - foreach my $b ($build, @{$dependents}) { - my $prevBuild = getPreviousBuild($b); + foreach my $build ($topbuild, @{$dependents}) { + my $prevBuild = getPreviousBuild($build); # Do we want to send mail for this build? unless ($ENV{'HYDRA_FORCE_SEND_MAIL'}) { - next unless $b->jobset->enableemail; + next unless $build->jobset->enableemail; # If build is cancelled or aborted, do not send email. - next if $b->buildstatus == 4 || $b->buildstatus == 3; + next if $build->buildstatus == 4 || $build->buildstatus == 3; # If there is a previous (that is not cancelled or aborted) build # with same buildstatus, do not send email. - next if defined $prevBuild && ($b->buildstatus == $prevBuild->buildstatus); + next if defined $prevBuild && ($build->buildstatus == $prevBuild->buildstatus); } - my $to = $b->jobset->emailoverride ne "" ? $b->jobset->emailoverride : $b->maintainers; + my $to = $build->jobset->emailoverride ne "" ? $build->jobset->emailoverride : $build->maintainers; foreach my $address (split ",", ($to // "")) { $address = trim $address; $addresses{$address} //= { builds => [] }; - push @{$addresses{$address}->{builds}}, $b; + push @{$addresses{$address}->{builds}}, $build; } } - my ($authors, $nrCommits, $emailable_authors) = getResponsibleAuthors($build, $self->{plugins}); + my ($authors, $nrCommits, $emailable_authors) = getResponsibleAuthors($topbuild, $self->{plugins}); my $authorList; - my $prevBuild = getPreviousBuild($build); + my $prevBuild = getPreviousBuild($topbuild); if (scalar keys %{$authors} > 0 && - ((!defined $prevBuild) || ($build->buildstatus != $prevBuild->buildstatus))) { + ((!defined $prevBuild) || ($topbuild->buildstatus != $prevBuild->buildstatus))) { my @x = map { "$_ <$authors->{$_}>" } (sort keys %{$authors}); $authorList = join(" or ", scalar @x > 1 ? join(", ", @x[0..scalar @x - 2]): (), $x[-1]); - $addresses{$_} = { builds => [ $build ] } foreach (@{$emailable_authors}); + $addresses{$_} = { builds => [ $topbuild ] } foreach (@{$emailable_authors}); } # Send an email to each interested address. @@ -96,11 +96,11 @@ sub buildFinished { my $tt = Template->new({}); my $vars = - { build => $build, prevBuild => getPreviousBuild($build) - , dependents => [grep { $_->id != $build->id } @builds] + { build => $topbuild, prevBuild => getPreviousBuild($topbuild) + , dependents => [grep { $_->id != $topbuild->id } @builds] , baseurl => getBaseUrl($self->{config}) , showJobName => \&showJobName, showStatus => \&showStatus - , showSystem => index($build->get_column('job'), $build->system) == -1 + , showSystem => index($topbuild->get_column('job'), $topbuild->system) == -1 , nrCommits => $nrCommits , authorList => $authorList }; @@ -113,16 +113,16 @@ sub buildFinished { $body =~ s/[\ ]+$//gm; my $subject = - showStatus($build) . ": Hydra job " . showJobName($build) - . ($vars->{showSystem} ? " on " . $build->system : "") + showStatus($topbuild) . ": Hydra job " . showJobName($topbuild) + . ($vars->{showSystem} ? " on " . $topbuild->system : "") . (scalar @{$vars->{dependents}} > 0 ? " (and " . scalar @{$vars->{dependents}} . " others)" : ""); sendEmail( $self->{config}, $to, $subject, $body, - [ 'X-Hydra-Project' => $build->get_column('project'), - , 'X-Hydra-Jobset' => $build->get_column('jobset'), - , 'X-Hydra-Job' => $build->get_column('job'), - , 'X-Hydra-System' => $build->system + [ 'X-Hydra-Project' => $topbuild->get_column('project'), + , 'X-Hydra-Jobset' => $topbuild->get_column('jobset'), + , 'X-Hydra-Job' => $topbuild->get_column('job'), + , 'X-Hydra-System' => $topbuild->system ]); } } From b4a19fd3c8e633b2aab9383ca1d03e117c81ee6f Mon Sep 17 00:00:00 2001 From: Graham Christensen Date: Fri, 20 Aug 2021 21:38:26 -0400 Subject: [PATCH 06/14] HIpChatNotification: $build -> $topbuild, $b -> $build (perlcritic) --- src/lib/Hydra/Plugin/HipChatNotification.pm | 30 ++++++++++----------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/lib/Hydra/Plugin/HipChatNotification.pm b/src/lib/Hydra/Plugin/HipChatNotification.pm index eb592d05..9a7385c4 100644 --- a/src/lib/Hydra/Plugin/HipChatNotification.pm +++ b/src/lib/Hydra/Plugin/HipChatNotification.pm @@ -11,7 +11,7 @@ sub isEnabled { } sub buildFinished { - my ($self, $build, $dependents) = @_; + my ($self, $topbuild, $dependents) = @_; my $cfg = $self->{config}->{hipchat}; my @config = defined $cfg ? ref $cfg eq "ARRAY" ? @$cfg : ($cfg) : (); @@ -21,46 +21,46 @@ sub buildFinished { # Figure out to which rooms to send notification. For each email # room, we send one aggregate message. my %rooms; - foreach my $b ($build, @{$dependents}) { - my $prevBuild = getPreviousBuild($b); - my $jobName = showJobName $b; + foreach my $build ($topbuild, @{$dependents}) { + my $prevBuild = getPreviousBuild($build); + my $jobName = showJobName $build; foreach my $room (@config) { my $force = $room->{force}; next unless $jobName =~ /^$room->{jobs}$/; # If build is cancelled or aborted, do not send email. - next if ! $force && ($b->buildstatus == 4 || $b->buildstatus == 3); + next if ! $force && ($build->buildstatus == 4 || $build->buildstatus == 3); # If there is a previous (that is not cancelled or aborted) build # with same buildstatus, do not send email. - next if ! $force && defined $prevBuild && ($b->buildstatus == $prevBuild->buildstatus); + next if ! $force && defined $prevBuild && ($build->buildstatus == $prevBuild->buildstatus); $rooms{$room->{room}} //= { room => $room, builds => [] }; - push @{$rooms{$room->{room}}->{builds}}, $b; + push @{$rooms{$room->{room}}->{builds}}, $build; } } return if scalar keys %rooms == 0; - my ($authors, $nrCommits) = getResponsibleAuthors($build, $self->{plugins}); + my ($authors, $nrCommits) = getResponsibleAuthors($topbuild, $self->{plugins}); # Send a message to each room. foreach my $roomId (keys %rooms) { my $room = $rooms{$roomId}; - my @deps = grep { $_->id != $build->id } @{$room->{builds}}; + my @deps = grep { $_->id != $topbuild->id } @{$room->{builds}}; my $img = - $build->buildstatus == 0 ? "$baseurl/static/images/checkmark_16.png" : - $build->buildstatus == 2 ? "$baseurl/static/images/dependency_16.png" : - $build->buildstatus == 4 ? "$baseurl/static/images/cancelled_16.png" : + $topbuild->buildstatus == 0 ? "$baseurl/static/images/checkmark_16.png" : + $topbuild->buildstatus == 2 ? "$baseurl/static/images/dependency_16.png" : + $topbuild->buildstatus == 4 ? "$baseurl/static/images/cancelled_16.png" : "$baseurl/static/images/error_16.png"; my $msg = ""; $msg .= " "; - $msg .= "Job get_column('jobset')}/${\$build->get_column('job')}'>${\showJobName($build)}"; + $msg .= "Job get_column('jobset')}/${\$topbuild->get_column('job')}'>${\showJobName($topbuild)}"; $msg .= " (and ${\scalar @deps} others)" if scalar @deps > 0; - $msg .= ": " . showStatus($build) . ""; + $msg .= ": " . showStatus($topbuild) . ""; if (scalar keys %{$authors} > 0) { # FIXME: HTML escaping @@ -79,7 +79,7 @@ sub buildFinished { message => $msg, message_format => 'html', notify => $room->{room}->{notify} || 0, - color => $build->buildstatus == 0 ? 'green' : 'red' }); + color => $topbuild->buildstatus == 0 ? 'green' : 'red' }); print STDERR $resp->status_line, ": ", $resp->decoded_content,"\n" if !$resp->is_success; } From bcf37ab7059116dcbf30a8c0e2b6bb98c515dfa5 Mon Sep 17 00:00:00 2001 From: Graham Christensen Date: Fri, 20 Aug 2021 21:40:25 -0400 Subject: [PATCH 07/14] GitlabStatus: $build -> $topbuild, $b -> $build (perlcritic) --- src/lib/Hydra/Plugin/GitlabStatus.pm | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/lib/Hydra/Plugin/GitlabStatus.pm b/src/lib/Hydra/Plugin/GitlabStatus.pm index ccbeb8d7..483d99bd 100644 --- a/src/lib/Hydra/Plugin/GitlabStatus.pm +++ b/src/lib/Hydra/Plugin/GitlabStatus.pm @@ -37,25 +37,25 @@ sub toGitlabState { } sub common { - my ($self, $build, $dependents, $status) = @_; + my ($self, $topbuild, $dependents, $status) = @_; my $baseurl = $self->{config}->{'base_uri'} || "http://localhost:3000"; # Find matching configs - foreach my $b ($build, @{$dependents}) { - my $jobName = showJobName $b; - my $evals = $build->jobsetevals; + foreach my $build ($topbuild, @{$dependents}) { + my $jobName = showJobName $build; + my $evals = $topbuild->jobsetevals; my $ua = LWP::UserAgent->new(); # Don't send out "pending/running" status updates if the build is already finished - next if $status < 2 && $b->finished == 1; + next if $status < 2 && $build->finished == 1; - my $state = toGitlabState($status, $b->buildstatus); + my $state = toGitlabState($status, $build->buildstatus); my $body = encode_json( { state => $state, - target_url => "$baseurl/build/" . $b->id, - description => "Hydra build #" . $b->id . " of $jobName", - name => "Hydra " . $b->get_column('job'), + target_url => "$baseurl/build/" . $build->id, + description => "Hydra build #" . $build->id . " of $jobName", + name => "Hydra " . $build->get_column('job'), }); while (my $eval = $evals->next) { my $gitlabstatusInput = $eval->jobsetevalinputs->find({ name => "gitlab_status_repo" }); From 3920bf1df30f4fc75738bce1804aa401c5a2fe42 Mon Sep 17 00:00:00 2001 From: Graham Christensen Date: Fri, 20 Aug 2021 21:42:56 -0400 Subject: [PATCH 08/14] BitBucketStatus: $build -> $topbuild, $b -> $build (perlcritic) --- src/lib/Hydra/Plugin/BitBucketStatus.pm | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/lib/Hydra/Plugin/BitBucketStatus.pm b/src/lib/Hydra/Plugin/BitBucketStatus.pm index f209c6f1..fee27070 100644 --- a/src/lib/Hydra/Plugin/BitBucketStatus.pm +++ b/src/lib/Hydra/Plugin/BitBucketStatus.pm @@ -22,21 +22,21 @@ sub toBitBucketState { } sub common { - my ($self, $build, $dependents, $finished) = @_; + my ($self, $topbuild, $dependents, $finished) = @_; my $bitbucket = $self->{config}->{bitbucket}; my $baseurl = $self->{config}->{'base_uri'} || "http://localhost:3000"; - foreach my $b ($build, @{$dependents}) { - my $jobName = showJobName $b; - my $evals = $build->jobsetevals; + foreach my $build ($topbuild, @{$dependents}) { + my $jobName = showJobName $build; + my $evals = $topbuild->jobsetevals; my $ua = LWP::UserAgent->new(); my $body = encode_json( { - state => $finished ? toBitBucketState($b->buildstatus) : "INPROGRESS", - url => "$baseurl/build/" . $b->id, + state => $finished ? toBitBucketState($tbuild->buildstatus) : "INPROGRESS", + url => "$baseurl/build/" . $tbuild->id, name => $jobName, - key => $b->id, - description => "Hydra build #" . $b->id . " of $jobName", + key => $tbuild->id, + description => "Hydra build #" . $tbuild->id . " of $jobName", }); while (my $eval = $evals->next) { foreach my $i ($eval->jobsetevalinputs){ From 5c9d8794b191ebc4adc843a35bb13cf4dd597baa Mon Sep 17 00:00:00 2001 From: Graham Christensen Date: Fri, 20 Aug 2021 21:44:30 -0400 Subject: [PATCH 09/14] GiteaStatus: $build -> $topbuild, $b -> $build (perlcritic) --- src/lib/Hydra/Plugin/GiteaStatus.pm | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/lib/Hydra/Plugin/GiteaStatus.pm b/src/lib/Hydra/Plugin/GiteaStatus.pm index b8da1d0f..75796053 100644 --- a/src/lib/Hydra/Plugin/GiteaStatus.pm +++ b/src/lib/Hydra/Plugin/GiteaStatus.pm @@ -29,25 +29,25 @@ sub toGiteaState { } sub common { - my ($self, $build, $dependents, $status) = @_; + my ($self, $topbuild, $dependents, $status) = @_; my $baseurl = $self->{config}->{'base_uri'} || "http://localhost:3000"; # Find matching configs - foreach my $b ($build, @{$dependents}) { - my $jobName = showJobName $b; - my $evals = $build->jobsetevals; + foreach my $build ($topbuild, @{$dependents}) { + my $jobName = showJobName $build; + my $evals = $topbuild->jobsetevals; my $ua = LWP::UserAgent->new(); # Don't send out "pending/running" status updates if the build is already finished - next if $status < 2 && $b->finished == 1; + next if $status < 2 && $build->finished == 1; - my $state = toGiteaState($status, $b->buildstatus); + my $state = toGiteaState($status, $build->buildstatus); my $body = encode_json( { state => $state, - target_url => "$baseurl/build/" . $b->id, - description => "Hydra build #" . $b->id . " of $jobName", - context => "Hydra " . $b->get_column('job'), + target_url => "$baseurl/build/" . $build->id, + description => "Hydra build #" . $build->id . " of $jobName", + context => "Hydra " . $build->get_column('job'), }); while (my $eval = $evals->next) { From b4f98072900625b72bfb8f96e3231c4e73e0cd5e Mon Sep 17 00:00:00 2001 From: Graham Christensen Date: Fri, 20 Aug 2021 21:45:50 -0400 Subject: [PATCH 10/14] GithubStatus: $build -> $topbuild, $b -> $build (perlcritic) --- src/lib/Hydra/Plugin/GithubStatus.pm | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/lib/Hydra/Plugin/GithubStatus.pm b/src/lib/Hydra/Plugin/GithubStatus.pm index 7d58c098..e3dfc533 100644 --- a/src/lib/Hydra/Plugin/GithubStatus.pm +++ b/src/lib/Hydra/Plugin/GithubStatus.pm @@ -25,32 +25,32 @@ sub toGithubState { } sub common { - my ($self, $build, $dependents, $finished) = @_; + my ($self, $topbuild, $dependents, $finished) = @_; my $cfg = $self->{config}->{githubstatus}; my @config = defined $cfg ? ref $cfg eq "ARRAY" ? @$cfg : ($cfg) : (); my $baseurl = $self->{config}->{'base_uri'} || "http://localhost:3000"; # Find matching configs - foreach my $b ($build, @{$dependents}) { - my $jobName = showJobName $b; - my $evals = $build->jobsetevals; + foreach my $build ($topbuild, @{$dependents}) { + my $jobName = showJobName $build; + my $evals = $topbuild->jobsetevals; my $ua = LWP::UserAgent->new(); foreach my $conf (@config) { next unless $jobName =~ /^$conf->{jobs}$/; # Don't send out "pending" status updates if the build is already finished - next if !$finished && $b->finished == 1; + next if !$finished && $build->finished == 1; - my $contextTrailer = $conf->{excludeBuildFromContext} ? "" : (":" . $b->id); + my $contextTrailer = $conf->{excludeBuildFromContext} ? "" : (":" . $build->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", + state => $finished ? toGithubState($build->buildstatus) : "pending", + target_url => "$baseurl/build/" . $build->id, + description => $conf->{description} // "Hydra build #" . $build->id . " of $jobName", context => $context }); my $inputs_cfg = $conf->{inputs}; From c929f5cac01dec556aa04b8d520f64b03a3fc743 Mon Sep 17 00:00:00 2001 From: Graham Christensen Date: Fri, 20 Aug 2021 21:49:32 -0400 Subject: [PATCH 11/14] SlackNotification: $build -> $topbuild, $b -> $build (perlcritic) --- src/lib/Hydra/Plugin/SlackNotification.pm | 36 +++++++++++------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/src/lib/Hydra/Plugin/SlackNotification.pm b/src/lib/Hydra/Plugin/SlackNotification.pm index e94e937b..387f92c4 100644 --- a/src/lib/Hydra/Plugin/SlackNotification.pm +++ b/src/lib/Hydra/Plugin/SlackNotification.pm @@ -77,7 +77,7 @@ sub renderDuration { } sub buildFinished { - my ($self, $build, $dependents) = @_; + my ($self, $topbuild, $dependents) = @_; my $cfg = $self->{config}->{slack}; my @config = defined $cfg ? ref $cfg eq "ARRAY" ? @$cfg : ($cfg) : (); @@ -86,12 +86,12 @@ sub buildFinished { # Figure out to which channelss to send notification. For each channel # we send one aggregate message. my %channels; - foreach my $b ($build, @{$dependents}) { - my $jobName = showJobName $b; - my $buildStatus = $b->buildstatus; + foreach my $build ($topbuild, @{$dependents}) { + my $jobName = showJobName $build; + my $buildStatus = $build->buildstatus; my $cancelledOrAborted = $buildStatus == 4 || $buildStatus == 3; - my $prevBuild = getPreviousBuild($b); + my $prevBuild = getPreviousBuild($build); my $sameAsPrevious = defined $prevBuild && ($buildStatus == $prevBuild->buildstatus); my $prevBuildStatus = (defined $prevBuild) ? $prevBuild->buildstatus : -1; my $prevBuildId = (defined $prevBuild) ? $prevBuild->id : -1; @@ -114,34 +114,34 @@ sub buildFinished { print STDERR "SlackNotification_Debug adding $jobName to the report list\n"; $channels{$channel->{url}} //= { channel => $channel, builds => [] }; - push @{$channels{$channel->{url}}->{builds}}, $b; + push @{$channels{$channel->{url}}->{builds}}, $build; } } return if scalar keys %channels == 0; - my ($authors, $nrCommits) = getResponsibleAuthors($build, $self->{plugins}); + my ($authors, $nrCommits) = getResponsibleAuthors($topbuild, $self->{plugins}); # Send a message to each room. foreach my $url (keys %channels) { my $channel = $channels{$url}; - my @deps = grep { $_->id != $build->id } @{$channel->{builds}}; + my @deps = grep { $_->id != $topbuild->id } @{$channel->{builds}}; my $img = - $build->buildstatus == 0 ? "$baseurl/static/images/checkmark_256.png" : - $build->buildstatus == 2 ? "$baseurl/static/images/dependency_256.png" : - $build->buildstatus == 4 ? "$baseurl/static/images/cancelled_256.png" : + $topbuild->buildstatus == 0 ? "$baseurl/static/images/checkmark_256.png" : + $topbuild->buildstatus == 2 ? "$baseurl/static/images/dependency_256.png" : + $topbuild->buildstatus == 4 ? "$baseurl/static/images/cancelled_256.png" : "$baseurl/static/images/error_256.png"; my $color = - $build->buildstatus == 0 ? "good" : - $build->buildstatus == 4 ? "warning" : + $topbuild->buildstatus == 0 ? "good" : + $topbuild->buildstatus == 4 ? "warning" : "danger"; my $text = ""; - $text .= "Job <$baseurl/job/${\$build->get_column('project')}/${\$build->get_column('jobset')}/${\$build->get_column('job')}|${\showJobName($build)}>"; + $text .= "Job <$baseurl/job/${\$topbuild->get_column('project')}/${\$topbuild->get_column('jobset')}/${\$topbuild->get_column('job')}|${\showJobName($topbuild)}>"; $text .= " (and ${\scalar @deps} others)" if scalar @deps > 0; - $text .= ": <$baseurl/build/${\$build->id}|" . showStatus($build) . ">". " in " . renderDuration($build); + $text .= ": <$baseurl/build/${\$topbuild->id}|" . showStatus($topbuild) . ">". " in " . renderDuration($topbuild); if (scalar keys %{$authors} > 0) { # FIXME: escaping @@ -155,12 +155,12 @@ sub buildFinished { my $msg = { attachments => - [{ fallback => "Job " . showJobName($build) . " build number " . $build->id . ": " . showStatus($build), + [{ fallback => "Job " . showJobName($topbuild) . " build number " . $topbuild->id . ": " . showStatus($topbuild), text => $text, thumb_url => $img, color => $color, - title => "Job " . showJobName($build) . " build number " . $build->id, - title_link => "$baseurl/build/${\$build->id}" + title => "Job " . showJobName($topbuild) . " build number " . $topbuild->id, + title_link => "$baseurl/build/${\$topbuild->id}" }] }; From 5e10648a9845a0a444932f5dd8e089ab8a5be1ea Mon Sep 17 00:00:00 2001 From: Graham Christensen Date: Fri, 20 Aug 2021 21:50:30 -0400 Subject: [PATCH 12/14] CoverityScan: $b -> $build (perlcritic) --- src/lib/Hydra/Plugin/CoverityScan.pm | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/lib/Hydra/Plugin/CoverityScan.pm b/src/lib/Hydra/Plugin/CoverityScan.pm index 1ee60843..f395100f 100644 --- a/src/lib/Hydra/Plugin/CoverityScan.pm +++ b/src/lib/Hydra/Plugin/CoverityScan.pm @@ -12,19 +12,19 @@ sub isEnabled { } sub buildFinished { - my ($self, $b, $dependents) = @_; + my ($self, $build, $dependents) = @_; my $cfg = $self->{config}->{coverityscan}; my @config = defined $cfg ? ref $cfg eq "ARRAY" ? @$cfg : ($cfg) : (); # Scan the job and see if it matches any of the Coverity Scan projects my $proj; - my $jobName = showJobName $b; + my $jobName = showJobName $build; foreach my $p (@config) { next unless $jobName =~ /^$p->{jobs}$/; # If build is cancelled or aborted, do not upload build - next if $b->buildstatus == 4 || $b->buildstatus == 3; + next if $build->buildstatus == 4 || $build->buildstatus == 3; # Otherwise, select this Coverity project $proj = $p; last; @@ -47,7 +47,7 @@ sub buildFinished { unless defined $token; # Get tarball locations - my $storePath = ($b->buildoutputs)[0]->path; + my $storePath = ($build->buildoutputs)[0]->path; my $tarballs = "$storePath/tarballs"; my $covTarball; @@ -87,7 +87,7 @@ sub buildFinished { unless defined $version; # Submit build - my $jobid = $b->id; + my $jobid = $build->id; my $desc = "Hydra Coverity Build ($jobName) - $jobid:$version"; print STDERR "uploading $desc ($shortName) to Coverity Scan\n"; From e9ba0b56f67015485f5b5b4a5f763513fb927f09 Mon Sep 17 00:00:00 2001 From: Graham Christensen Date: Fri, 20 Aug 2021 21:51:39 -0400 Subject: [PATCH 13/14] BuildFinished : $b -> $build (perlcritic) --- src/lib/Hydra/Event/BuildFinished.pm | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/lib/Hydra/Event/BuildFinished.pm b/src/lib/Hydra/Event/BuildFinished.pm index dc94b5ee..4c4aa647 100644 --- a/src/lib/Hydra/Event/BuildFinished.pm +++ b/src/lib/Hydra/Event/BuildFinished.pm @@ -53,9 +53,9 @@ sub execute { # # Otherwise, the dependent builds will remain with notificationpendingsince set # until hydra-notify is started, as buildFinished is never emitted for them. - foreach my $b ($self->{"build"}, @{$self->{"dependents"}}) { - if ($b->finished && defined($b->notificationpendingsince)) { - $b->update({ notificationpendingsince => undef }) + foreach my $build ($self->{"build"}, @{$self->{"dependents"}}) { + if ($build->finished && defined($build->notificationpendingsince)) { + $build->update({ notificationpendingsince => undef }) } } From ca4b8d449ff4eecf26e4b0096b0a5aab056052f4 Mon Sep 17 00:00:00 2001 From: Graham Christensen Date: Mon, 6 Sep 2021 21:12:13 -0400 Subject: [PATCH 14/14] BitBucketStatus: tbuild -> build (typo) --- src/lib/Hydra/Plugin/BitBucketStatus.pm | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/lib/Hydra/Plugin/BitBucketStatus.pm b/src/lib/Hydra/Plugin/BitBucketStatus.pm index fee27070..097bed00 100644 --- a/src/lib/Hydra/Plugin/BitBucketStatus.pm +++ b/src/lib/Hydra/Plugin/BitBucketStatus.pm @@ -32,11 +32,11 @@ sub common { my $ua = LWP::UserAgent->new(); my $body = encode_json( { - state => $finished ? toBitBucketState($tbuild->buildstatus) : "INPROGRESS", - url => "$baseurl/build/" . $tbuild->id, + state => $finished ? toBitBucketState($build->buildstatus) : "INPROGRESS", + url => "$baseurl/build/" . $build->id, name => $jobName, - key => $tbuild->id, - description => "Hydra build #" . $tbuild->id . " of $jobName", + key => $build->id, + description => "Hydra build #" . $build->id . " of $jobName", }); while (my $eval = $evals->next) { foreach my $i ($eval->jobsetevalinputs){