Search in sources :

Example 1 with CommandBuilder

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));
}
Also used : CommandBuilder(com.thoughtworks.go.domain.builder.CommandBuilder) Builder(com.thoughtworks.go.domain.builder.Builder) RunIfConfigs(com.thoughtworks.go.domain.RunIfConfigs) CommandBuilder(com.thoughtworks.go.domain.builder.CommandBuilder) File(java.io.File) Test(org.junit.Test)

Example 2 with CommandBuilder

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");
}
Also used : Builder(com.thoughtworks.go.domain.builder.Builder) CommandBuilder(com.thoughtworks.go.domain.builder.CommandBuilder) CommandBuilder(com.thoughtworks.go.domain.builder.CommandBuilder) File(java.io.File)

Example 3 with CommandBuilder

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);
    }
}
Also used : Builder(com.thoughtworks.go.domain.builder.Builder) CommandBuilder(com.thoughtworks.go.domain.builder.CommandBuilder) CommandBuilderWithArgList(com.thoughtworks.go.domain.builder.CommandBuilderWithArgList) CommandBuilder(com.thoughtworks.go.domain.builder.CommandBuilder) File(java.io.File)

Example 4 with CommandBuilder

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));
}
Also used : CommandBuilder(com.thoughtworks.go.domain.builder.CommandBuilder) File(java.io.File) Test(org.junit.Test) TasksTest(com.thoughtworks.go.domain.TasksTest)

Example 5 with CommandBuilder

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"));
}
Also used : ExecTask(com.thoughtworks.go.config.ExecTask) CommandBuilder(com.thoughtworks.go.domain.builder.CommandBuilder) RunIf(com.googlecode.junit.ext.RunIf) Test(org.junit.Test) TasksTest(com.thoughtworks.go.domain.TasksTest)

Aggregations

CommandBuilder (com.thoughtworks.go.domain.builder.CommandBuilder)22 Test (org.junit.Test)17 TasksTest (com.thoughtworks.go.domain.TasksTest)16 File (java.io.File)16 NantTask (com.thoughtworks.go.config.NantTask)9 RunIf (com.googlecode.junit.ext.RunIf)6 Builder (com.thoughtworks.go.domain.builder.Builder)6 ExecTask (com.thoughtworks.go.config.ExecTask)2 AntTask (com.thoughtworks.go.config.AntTask)1 RakeTask (com.thoughtworks.go.config.RakeTask)1 RunIfConfigs (com.thoughtworks.go.domain.RunIfConfigs)1 BuildCause (com.thoughtworks.go.domain.buildcause.BuildCause)1 CommandBuilderWithArgList (com.thoughtworks.go.domain.builder.CommandBuilderWithArgList)1 NullBuilder (com.thoughtworks.go.domain.builder.NullBuilder)1 ArrayList (java.util.ArrayList)1