public BuildCommand setRunIfRecurisvely(String runIfConfig) { runIf(runIfConfig); for (BuildCommand subCommand : subCommands) { subCommand.setRunIfRecurisvely(runIfConfig); } return this; }
private BuildCommand runSingleBuilder(Builder builder) { String runIfConfig = builder.resolvedRunIfConfig().toString(); return BuildCommand.compose( echoWithPrefix("Current job status: passed"), echoWithPrefix("Current job status: failed").runIf("failed"), echoWithPrefix("Task: %s", builder.getDescription()).runIf(runIfConfig), builder.buildCommand() .runIf(runIfConfig) .setOnCancel(runCancelTask(builder.getCancelBuilder()))).runIf(runIfConfig); }
@Test public void shouldRunCommandWithRunIfAnyRegardlessOfBuildResult() { runBuild(compose( echo("foo"), echo("on passing").runIf("any"), fail("force failure"), echo("on failure").runIf("any")), Failed); assertThat(console.asList(), is(Arrays.asList("foo", "on passing", "force failure", "on failure"))); }
public BuildCommand compose() { return BuildCommand.compose( echoWithPrefix("Job Started: ${date}"), prepare(), build(), reportAction("Job completed").runIf("any")) .setOnCancel(BuildCommand.compose( reportAction("Job is canceled"), reportAction("Job completed"))); }
@Test public void shouldNotRunCommandWithRunIfFailedIfBuildIsPassing() { runBuild(compose( echo("on pass"), echo("on failure").runIf("failed")), Passed); assertThat(console.asList(), is(Collections.singletonList("on pass"))); }
@Test public void defaultRunIfIsPassed() { assertThat(new BuildCommand("cmd").getRunIfConfig(), is("passed")); assertThat(new BuildCommand("cmd").runIf("any").getRunIfConfig(), is("any")); }
@Test public void shouldRunCommandWithRunIfFailedIfBuildIsFailed() { runBuild(compose( fail("force failure"), echo("on failure").runIf("failed")), Failed); assertThat(console.lastLine(), is("on failure")); }