forked from lix-project/hydra
DynamicRunCommand: don't run if the build failed
This commit is contained in:
parent
1a30a0c2f1
commit
216d8bee35
|
@ -40,6 +40,10 @@ sub areDynamicCommandsEnabled {
|
||||||
sub isBuildEligibleForDynamicRunCommand {
|
sub isBuildEligibleForDynamicRunCommand {
|
||||||
my ($build) = @_;
|
my ($build) = @_;
|
||||||
|
|
||||||
|
if ($build->get_column("buildstatus") != 0) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
if ($build->get_column("job") =~ "^runCommandHook\..+") {
|
if ($build->get_column("job") =~ "^runCommandHook\..+") {
|
||||||
my $out = $build->buildoutputs->find({name => "out"});
|
my $out = $build->buildoutputs->find({name => "out"});
|
||||||
if (!defined $out) {
|
if (!defined $out) {
|
||||||
|
@ -135,7 +139,6 @@ sub fanoutToCommands {
|
||||||
# missing test cases:
|
# missing test cases:
|
||||||
#
|
#
|
||||||
# 1. is it enabled on the jobset?
|
# 1. is it enabled on the jobset?
|
||||||
# 2. what if the build failed?
|
|
||||||
if (isBuildEligibleForDynamicRunCommand($build)) {
|
if (isBuildEligibleForDynamicRunCommand($build)) {
|
||||||
my $job = $build->get_column('job');
|
my $job = $build->get_column('job');
|
||||||
my $out = $build->buildoutputs->find({name => "out"});
|
my $out = $build->buildoutputs->find({name => "out"});
|
||||||
|
|
|
@ -159,6 +159,14 @@ subtest "isBuildEligibleForDynamicRunCommand" => sub {
|
||||||
"out is a symlink to a directory"
|
"out is a symlink to a directory"
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
subtest "On build status ..." => sub {
|
||||||
|
is(
|
||||||
|
Hydra::Plugin::RunCommand::isBuildEligibleForDynamicRunCommand($builds->{"runCommandHook.failed"}),
|
||||||
|
0,
|
||||||
|
"Failed builds don't get run"
|
||||||
|
);
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -127,4 +127,22 @@ rec {
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
runCommandHook.failed = mkDerivation {
|
||||||
|
name = "failed";
|
||||||
|
builder = "/bin/sh";
|
||||||
|
outputs = [ "out" ];
|
||||||
|
args = [
|
||||||
|
(
|
||||||
|
builtins.toFile "builder.sh" ''
|
||||||
|
#! /bin/sh
|
||||||
|
|
||||||
|
touch $out
|
||||||
|
chmod +x $out
|
||||||
|
|
||||||
|
exit 1
|
||||||
|
''
|
||||||
|
)
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue