Search in sources :

Example 16 with CommandBuilder

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

the class BuildWorkEnvironmentVariablesTest method getBuildWorkWithP4MaterialRevision.

private BuildWork getBuildWorkWithP4MaterialRevision(P4Material p4Material) {
    pipelineConfig.setMaterialConfigs(new Materials(p4Material).convertToConfigs());
    JobPlan plan = new DefaultJobPlan(new Resources(), new ArrayList<>(), new ArrayList<>(), -1, new JobIdentifier(PIPELINE_NAME, 1, "1", STAGE_NAME, "1", JOB_NAME, 123L), null, new EnvironmentVariables(), new EnvironmentVariables(), null);
    MaterialRevisions materialRevisions = new MaterialRevisions(new MaterialRevision(p4Material, new Modification("user", "comment", "a@b.com", new Date(), "10")));
    BuildCause buildCause = BuildCause.createWithModifications(materialRevisions, TRIGGERED_BY_USER);
    List<Builder> builders = new ArrayList<>();
    builders.add(new CommandBuilder("ant", "", dir, new RunIfConfigs(), new NullBuilder(), ""));
    BuildAssignment assignment = BuildAssignment.create(plan, buildCause, builders, dir, environmentVariableContext, new ArtifactStores());
    return new BuildWork(assignment, systemEnvironment.consoleLogCharset());
}
Also used : Modification(com.thoughtworks.go.domain.materials.Modification) ArtifactStores(com.thoughtworks.go.config.ArtifactStores) Materials(com.thoughtworks.go.config.materials.Materials) 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) Date(java.util.Date) BuildCause(com.thoughtworks.go.domain.buildcause.BuildCause) CommandBuilder(com.thoughtworks.go.domain.builder.CommandBuilder)

Example 17 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 18 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 19 with CommandBuilder

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

the class AntTaskBuilderTest method shouldUseAbsoluteWorkingDirectoryWhenItIsSet.

@Test
public void shouldUseAbsoluteWorkingDirectoryWhenItIsSet() {
    final File absoluteFile = new File("me/antdirectory").getAbsoluteFile();
    antTask.setWorkingDirectory(absoluteFile.getPath());
    CommandBuilder builder = (CommandBuilder) antTaskBuilder.createBuilder(builderFactory, antTask, pipeline, resolver);
    assertThat(builder.getWorkingDir(), is(absoluteFile));
}
Also used : CommandBuilder(com.thoughtworks.go.domain.builder.CommandBuilder) File(java.io.File) Test(org.junit.Test) TasksTest(com.thoughtworks.go.domain.TasksTest)

Example 20 with CommandBuilder

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

the class AntTaskBuilderTest method shouldPrependDefaultWorkingDirectoryIfRelativeAntHomeIsUsed.

@Test
public void shouldPrependDefaultWorkingDirectoryIfRelativeAntHomeIsUsed() {
    antTask.setWorkingDirectory("lib");
    File baseDir = new File(DEFAULT_WORKING_DIRECTORY);
    CommandBuilder builder = (CommandBuilder) antTaskBuilder.createBuilder(builderFactory, antTask, pipeline, resolver);
    assertThat(builder.getWorkingDir(), is(new File(baseDir, "lib")));
}
Also used : CommandBuilder(com.thoughtworks.go.domain.builder.CommandBuilder) File(java.io.File) Test(org.junit.Test) TasksTest(com.thoughtworks.go.domain.TasksTest)

Aggregations

CommandBuilder (com.thoughtworks.go.domain.builder.CommandBuilder)26 Test (org.junit.Test)18 File (java.io.File)17 TasksTest (com.thoughtworks.go.domain.TasksTest)16 NantTask (com.thoughtworks.go.config.NantTask)9 Builder (com.thoughtworks.go.domain.builder.Builder)9 RunIf (com.googlecode.junit.ext.RunIf)6 BuildCause (com.thoughtworks.go.domain.buildcause.BuildCause)4 NullBuilder (com.thoughtworks.go.domain.builder.NullBuilder)4 ArtifactStores (com.thoughtworks.go.config.ArtifactStores)3 ArrayList (java.util.ArrayList)3 ExecTask (com.thoughtworks.go.config.ExecTask)2 RunIfConfigs (com.thoughtworks.go.domain.RunIfConfigs)2 StubBuilder (com.thoughtworks.go.domain.builder.StubBuilder)2 EnvironmentVariableContext (com.thoughtworks.go.util.command.EnvironmentVariableContext)2 AntTask (com.thoughtworks.go.config.AntTask)1 RakeTask (com.thoughtworks.go.config.RakeTask)1 Materials (com.thoughtworks.go.config.materials.Materials)1 StubGoPublisher (com.thoughtworks.go.domain.StubGoPublisher)1 CommandBuilderWithArgList (com.thoughtworks.go.domain.builder.CommandBuilderWithArgList)1