Search in sources :

Example 11 with CommandBuilder

use of com.thoughtworks.go.domain.builder.CommandBuilder in project gocd by gocd.

the class RakeTaskBuilderTest method rakeTaskShouldNormalizeWorkingDirectory.

@Test
@RunIf(value = EnhancedOSChecker.class, arguments = { DO_NOT_RUN_ON, WINDOWS })
public void rakeTaskShouldNormalizeWorkingDirectory() throws Exception {
    RakeTask task = new RakeTask();
    task.setWorkingDirectory("folder1\\folder2");
    CommandBuilder commandBuilder = (CommandBuilder) rakeTaskBuilder.createBuilder(builderFactory, task, TasksTest.pipelineStub("label", "/var/cruise-agent/pipelines/cruise"), resolver);
    assertThat(commandBuilder.getWorkingDir().getPath(), is("/var/cruise-agent/pipelines/cruise/folder1/folder2"));
}
Also used : RakeTask(com.thoughtworks.go.config.RakeTask) CommandBuilder(com.thoughtworks.go.domain.builder.CommandBuilder) RunIf(com.googlecode.junit.ext.RunIf) Test(org.junit.Test) TasksTest(com.thoughtworks.go.domain.TasksTest)

Example 12 with CommandBuilder

use of com.thoughtworks.go.domain.builder.CommandBuilder in project gocd by gocd.

the class BuildWorkEnvironmentVariablesTest method createAssignment.

private BuildAssignment createAssignment() {
    JobPlan plan = new DefaultJobPlan(new Resources(), new ArtifactPlans(), new ArtifactPropertiesGenerators(), -1, new JobIdentifier(PIPELINE_NAME, 1, "1", STAGE_NAME, "1", JOB_NAME, 123L), null, new EnvironmentVariablesConfig(), new EnvironmentVariablesConfig(), null);
    MaterialRevisions materialRevisions = materialRevisions();
    BuildCause buildCause = BuildCause.createWithModifications(materialRevisions, TRIGGERED_BY_USER);
    List<Builder> builders = new ArrayList<>();
    builders.add(new CommandBuilder("ant", "", dir, new RunIfConfigs(), new NullBuilder(), ""));
    return BuildAssignment.create(plan, buildCause, builders, dir);
}
Also used : CommandBuilder(com.thoughtworks.go.domain.builder.CommandBuilder) Builder(com.thoughtworks.go.domain.builder.Builder) NullBuilder(com.thoughtworks.go.domain.builder.NullBuilder) ArrayList(java.util.ArrayList) NullBuilder(com.thoughtworks.go.domain.builder.NullBuilder) BuildCause(com.thoughtworks.go.domain.buildcause.BuildCause) CommandBuilder(com.thoughtworks.go.domain.builder.CommandBuilder)

Example 13 with CommandBuilder

use of com.thoughtworks.go.domain.builder.CommandBuilder in project gocd by gocd.

the class NantTaskBuilder method createBuilder.

@Override
public Builder createBuilder(BuilderFactory builderFactory, NantTask task, Pipeline pipeline, UpstreamPipelineResolver resolver) {
    File taskWorkingDirectory = new File(FileUtil.join(pipeline.defaultWorkingFolder(), task.workingDirectory()));
    String command = task.command();
    String argument = task.arguments();
    Builder cancelBuilder = builderFactory.builderFor(task.cancelTask(), pipeline, resolver);
    return new CommandBuilder(command, argument, taskWorkingDirectory, 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 14 with CommandBuilder

use of com.thoughtworks.go.domain.builder.CommandBuilder in project gocd by gocd.

the class RakeTaskBuilder method createBuilder.

@Override
public Builder createBuilder(BuilderFactory builderFactory, RakeTask task, Pipeline pipeline, UpstreamPipelineResolver resolver) {
    String newWorkingDir = FileUtil.join(pipeline.defaultWorkingFolder(), task.workingDirectory());
    String argument = task.arguments();
    Builder builder = builderFactory.builderFor(task.cancelTask(), pipeline, resolver);
    return new CommandBuilder("rake", argument, new File(newWorkingDir), task.getConditions(), builder, task.describe());
}
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 15 with CommandBuilder

use of com.thoughtworks.go.domain.builder.CommandBuilder in project gocd by gocd.

the class NantTaskBuilderTest method shouldSetTargetWhenTargetIsSpecified.

@Test
public void shouldSetTargetWhenTargetIsSpecified() throws Exception {
    NantTask nantTask = new NantTask();
    nantTask.setTarget("unit-test");
    CommandBuilder commandBuilder = (CommandBuilder) nantTaskBuilder.createBuilder(builderFactory, nantTask, pipeline, resolver);
    assertThat(commandBuilder.getArgs(), is(" unit-test"));
}
Also used : NantTask(com.thoughtworks.go.config.NantTask) CommandBuilder(com.thoughtworks.go.domain.builder.CommandBuilder) 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