use of com.thoughtworks.go.domain.builder.CommandBuilder in project gocd by gocd.
the class BuildersTest method shouldNotSetAsCurrentBuilderIfNotRun.
@Test
public void shouldNotSetAsCurrentBuilderIfNotRun() throws CruiseControlException {
Builder builder = new CommandBuilder("echo", "", new File("."), new RunIfConfigs(FAILED), null, "");
Builders builders = new Builders(Arrays.asList(builder), null, null, null);
builders.setIsCancelled(true);
builders.build(environmentVariableContext);
Builders expected = new Builders(Arrays.asList(builder), null, null, null);
expected.setIsCancelled(true);
assertThat(builders, is(expected));
}
use of com.thoughtworks.go.domain.builder.CommandBuilder in project gocd by gocd.
the class AntTaskBuilder method createBuilder.
@Override
public Builder createBuilder(BuilderFactory builderFactory, AntTask task, Pipeline pipeline, UpstreamPipelineResolver resolver) {
String newWorkingDir = FileUtil.join(pipeline.defaultWorkingFolder(), task.workingDirectory());
String argument = task.arguments();
Builder cancelBuilder = builderFactory.builderFor(task.cancelTask(), pipeline, resolver);
return new CommandBuilder("ant", argument, new File(newWorkingDir), task.getConditions(), cancelBuilder, task.describe(), "BUILD FAILED");
}
use of com.thoughtworks.go.domain.builder.CommandBuilder in project gocd by gocd.
the class ExecTaskBuilder method createBuilder.
@Override
public Builder createBuilder(BuilderFactory builderFactory, ExecTask task, Pipeline pipeline, UpstreamPipelineResolver pipelineResolver) {
String workingDir = task.workingDirectory();
String command = task.command();
File newWorkingDir = workingDir == null ? pipeline.defaultWorkingFolder() : new File(applyBaseDirIfRelativeAndNormalize(pipeline.defaultWorkingFolder(), new File(workingDir)));
Builder builder = builderFactory.builderFor(task.cancelTask(), pipeline, pipelineResolver);
String description = task.describe();
if (!task.getArgList().isEmpty()) {
return new CommandBuilderWithArgList(command, task.getArgList().toStringArray(), newWorkingDir, task.getConditions(), builder, description);
} else {
return new CommandBuilder(command, task.getArgs(), newWorkingDir, task.getConditions(), builder, description);
}
}
use of com.thoughtworks.go.domain.builder.CommandBuilder in project gocd by gocd.
the class AntTaskBuilderTest method shouldUseDefaultWorkingDirectoryWhenItIsNotSet.
@Test
public void shouldUseDefaultWorkingDirectoryWhenItIsNotSet() throws Exception {
File workingDir = new File(DEFAULT_WORKING_DIRECTORY);
CommandBuilder builder = (CommandBuilder) antTaskBuilder.createBuilder(builderFactory, antTask, pipeline, resolver);
assertThat(builder.getWorkingDir(), is(workingDir));
}
use of com.thoughtworks.go.domain.builder.CommandBuilder in project gocd by gocd.
the class ExecTaskBuilderTest method shouldNormalizeWorkingDirectory.
@Test
@RunIf(value = EnhancedOSChecker.class, arguments = { DO_NOT_RUN_ON, WINDOWS })
public void shouldNormalizeWorkingDirectory() throws Exception {
ExecTask execTask = new ExecTask("ant", "", "folder\\child");
CommandBuilder builder = (CommandBuilder) execTaskBuilder.createBuilder(builderFactory, execTask, TasksTest.pipelineStub("label", "."), resolver);
assertThat(builder.getWorkingDir().getPath(), is("./folder/child"));
}
Aggregations