public static BuildCommand reportCompleting() { return new BuildCommand("reportCompleting"); }
public static BuildCommand plugin(Map<String, String> properties) { return new BuildCommand("plugin", properties); }
public static BuildCommand downloadFile(Map<String, String> args) { return new BuildCommand("downloadFile", args); }
public static BuildCommand downloadDir(Map<String, String> args) { return new BuildCommand("downloadDir", args); }
public static BuildCommand generateTestReport(List<String> srcs, String uploadPath) { return new BuildCommand("generateTestReport", map( "uploadPath", uploadPath, "srcs", GSON.toJson(srcs))); }
public static BuildCommand mkdirs(String path) { return new BuildCommand("mkdirs", map("path", path)); }
public static BuildCommand test(String flag, String left) { return new BuildCommand("test", map("flag", flag, "left", left)); }
public static BuildCommand exec(String command, String...args) { return new BuildCommand("exec", map("command", command, "args", GSON.toJson(args))); }
public static BuildCommand uploadArtifact(String src, String dest, boolean ignoreUnmatchError) { return new BuildCommand("uploadArtifact", map("src", src, "dest", dest, "ignoreUnmatchError", String.valueOf(ignoreUnmatchError))); }
public static BuildCommand compose(List<BuildCommand> subCommands) { return new BuildCommand("compose").setSubCommands(subCommands); }
public static BuildCommand cleandir(String path, String...allowedPaths) { return new BuildCommand("cleandir", map("path", path, "allowed", GSON.toJson(allowedPaths))); }
public static BuildCommand secret(String secretValue) { return new BuildCommand("secret", map("value", secretValue)); }
public static BuildCommand error(String message) { return new BuildCommand("error", map("message", message)); }
public static BuildCommand test(String flag, String left, BuildCommand subCommand) { return new BuildCommand("test", map("flag", flag, "left", left)) .setSubCommands(Collections.singletonList(subCommand)); }
public static BuildCommand reportCurrentStatus(JobState status) { return new BuildCommand("reportCurrentStatus", map("status", status.name())); }
@Test public void defaultSubCommandsShouldBeEmpty() { assertThat(new BuildCommand("foo").getSubCommands().size(), is(0)); assertThat(new BuildCommand("foo", map("arg1", "42")).getSubCommands().size(), is(0)); }
@Test public void testDumpComposedCommand() { assertThat(BuildCommand.compose(new BuildCommand("bar1"), BuildCommand.compose(new BuildCommand("barz"))).dump(), is("compose\n bar1\n compose\n barz")); }
@Test public void testGetArgs() { assertThat(new BuildCommand("foo", map("foo", new Gson().toJson(new String[]{"arg1", "arg2"}))).getArrayArg("foo"), is(new String[]{"arg1","arg2"})); assertThat(new BuildCommand("foo", map("foo", "true")).getBooleanArg("foo"), is(true)); assertThat(new BuildCommand("foo", map("foo", "true")).getBooleanArg("bar"), is(false)); assertThat(new BuildCommand("foo", map("foo", "bar")).getStringArg("foo"), is("bar")); }
@Test public void defaultRunIfIsPassed() { assertThat(new BuildCommand("cmd").getRunIfConfig(), is("passed")); assertThat(new BuildCommand("cmd").runIf("any").getRunIfConfig(), is("any")); }
@Test public void encodeDecode() { BuildCommand bc = BuildCommand.compose(new BuildCommand("bar1", map("arg1", "1", "arg2", "2")), BuildCommand.compose(new BuildCommand("barz"))); bc.setRunIfConfig("any"); bc.setTest(new BuildCommand("t", map("k1", "v1"))); bc.setOnCancel(BuildCommand.compose(BuildCommand.echo("foo"), BuildCommand.echo("bar"))); assertThat(MessageEncoding.decodeData(MessageEncoding.encodeData(bc), BuildCommand.class), is(bc)); } }