7FJKVZANSG7N3PCMISLNGVDSPNQ6UWNGNJWUNLVBQBFJW33UGIIQC sub fanoutToCommands {my ($config, $event, $project, $jobset, $job) = @_;my @commands;my $cfg = $config->{runcommand};my @config = defined $cfg ? ref $cfg eq "ARRAY" ? @$cfg : ($cfg) : ();foreach my $conf (@config) {my $matcher = $conf->{job} // "*:*:*";next unless eventMatches($conf, $event);next unless configSectionMatches($matcher,$project,$jobset,$job);if (!defined($conf->{command})) {warn "<runcommand> section for '$matcher' lacks a 'command' option";next;}push(@commands, {matcher => $matcher,command => $conf->{command},})}return \@commands;}
foreach my $conf (@config) {next unless eventMatches($conf, $event);next unless configSectionMatches($conf->{job} // "*:*:*",$build->get_column('project'),$build->get_column('jobset'),$build->get_column('job'));my $command = $conf->{command} // die "<runcommand> section lacks a 'command' option";unless (defined $tmp) {$tmp = File::Temp->new(SUFFIX => '.json');print $tmp encode_json(makeJsonPayload($event, $build)) or die;}
if (@$commandsToRun == 0) {# No matching jobs, don't bother generating the JSONreturn;}
);};subtest "fanoutToCommands" => sub {my $config = {runcommand => [{job => "",command => "foo"},{job => "project:*:*",command => "bar"},{job => "project:jobset:nomatch",command => "baz"}]};is(Hydra::Plugin::RunCommand::fanoutToCommands($config,"buildFinished","project","jobset","job"),[{matcher => "",command => "foo"},{matcher => "project:*:*",command => "bar"}],"fanoutToCommands returns a command per matching job"