use of com.thoughtworks.go.domain.RunIfConfigs in project gocd by gocd.
the class ConfigConverterTest method shouldMigrateRakeTaskToCR.
@Test
void shouldMigrateRakeTaskToCR() {
RakeTask rakeTask = new RakeTask();
rakeTask.setBuildFile("Rakefile.rb");
rakeTask.setWorkingDirectory("src");
rakeTask.setTarget("build");
rakeTask.setConditions(new RunIfConfigs(RunIfConfig.FAILED));
CRBuildTask result = (CRBuildTask) configConverter.taskToCRTask(rakeTask);
assertThat(result.getType()).isEqualTo(CRBuildFramework.rake);
assertThat(result.getBuildFile()).isEqualTo("Rakefile.rb");
assertThat(result.getTarget()).isEqualTo("build");
assertThat(result.getWorkingDirectory()).isEqualTo("src");
assertThat(result.getRunIf()).isEqualTo(CRRunIf.failed);
}
use of com.thoughtworks.go.domain.RunIfConfigs in project gocd by gocd.
the class BaseTaskRepresenter method fromJSON.
public static AbstractTask fromJSON(JsonReader jsonReader, AbstractTask task) {
RunIfConfigs runIfConfigs = new RunIfConfigs();
jsonReader.readArrayIfPresent("run_if", configs -> {
configs.forEach(runIfConfig -> {
runIfConfigs.add(new RunIfConfig(runIfConfig.getAsString()));
});
});
task.setConditions(runIfConfigs);
jsonReader.optJsonObject("on_cancel").ifPresent(onCancelReader -> {
OnCancelConfig onCancelConfig = OnCancelRepresenter.fromJSON(jsonReader.readJsonObject("on_cancel"));
task.setOnCancelConfig(onCancelConfig);
});
return task;
}
use of com.thoughtworks.go.domain.RunIfConfigs in project gocd by gocd.
the class BuilderTest method shouldReportErrorWhenCancelCommandDoesNotExist.
@Test
@DisabledOnOs(OS.WINDOWS)
void shouldReportErrorWhenCancelCommandDoesNotExist() {
StubBuilder stubBuilder = new StubBuilder();
CommandBuilder cancelBuilder = new CommandBuilder("echo2", "cancel task", new File("."), new RunIfConfigs(FAILED), stubBuilder, "");
CommandBuilder builder = new CommandBuilder("echo", "normal task", new File("."), new RunIfConfigs(FAILED), cancelBuilder, "");
builder.cancel(goPublisher, new EnvironmentVariableContext(), null, null, "utf-8");
assertThat(goPublisher.getMessage()).contains("Error happened while attempting to execute 'echo2 cancel task'");
}
use of com.thoughtworks.go.domain.RunIfConfigs in project gocd by gocd.
the class BuildersTest method shouldNotSetAsCurrentBuilderIfNotRun.
@Test
public void shouldNotSetAsCurrentBuilderIfNotRun() throws Exception {
EnvironmentVariableContext environmentVariableContext = new EnvironmentVariableContext();
Builder builder = new CommandBuilder("echo", "", new File("."), new RunIfConfigs(FAILED), null, "");
Builders builders = new Builders(Collections.singletonList(builder), null, null, null, null);
builders.setIsCancelled(true);
builders.build(environmentVariableContext, "utf-8");
Builders expected = new Builders(Collections.singletonList(builder), null, null, null, null);
expected.setIsCancelled(true);
assertThat(builders, is(expected));
}
use of com.thoughtworks.go.domain.RunIfConfigs in project gocd by gocd.
the class BuildersTest method shouldNotCancelAnythingIfAllBuildersHaveRun.
@Test
public void shouldNotCancelAnythingIfAllBuildersHaveRun() throws Exception {
EnvironmentVariableContext environmentVariableContext = new EnvironmentVariableContext();
Builder builder = new StubBuilder(new RunIfConfigs(ANY));
Builders builders = new Builders(Collections.singletonList(builder), new StubGoPublisher(), null, null, null);
builders.build(environmentVariableContext, "utf-8");
builders.cancel(environmentVariableContext, "utf-8");
}
Aggregations