Search in sources :

Example 11 with Builder

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

Example 12 with Builder

use of com.thoughtworks.go.domain.builder.Builder 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");
}
Also used : StubGoPublisher(com.thoughtworks.go.domain.StubGoPublisher) CommandBuilder(com.thoughtworks.go.domain.builder.CommandBuilder) Builder(com.thoughtworks.go.domain.builder.Builder) StubBuilder(com.thoughtworks.go.domain.builder.StubBuilder) RunIfConfigs(com.thoughtworks.go.domain.RunIfConfigs) EnvironmentVariableContext(com.thoughtworks.go.util.command.EnvironmentVariableContext) StubBuilder(com.thoughtworks.go.domain.builder.StubBuilder) Test(org.junit.Test)

Example 13 with Builder

use of com.thoughtworks.go.domain.builder.Builder 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 14 with Builder

use of com.thoughtworks.go.domain.builder.Builder 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 15 with Builder

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

the class FetchTaskBuilder method createBuilder.

@Override
public Builder createBuilder(BuilderFactory builderFactory, AbstractFetchTask task, Pipeline pipeline, UpstreamPipelineResolver resolver) {
    final JobIdentifier fetchFrom = resolveTargetJob(task, pipeline, resolver);
    final Builder cancelBuilder = builderFactory.builderFor(task.cancelTask(), pipeline, resolver);
    final ChecksumFileHandler checksumHandler = getChecksumHandler(task, pipeline.getName());
    if (task instanceof FetchTask) {
        return createFetchTaskBuilder((FetchTask) task, pipeline, fetchFrom, cancelBuilder, checksumHandler);
    } else {
        return createPluggableFetchTaskBuilder((FetchPluggableArtifactTask) task, pipeline, fetchFrom, cancelBuilder, checksumHandler);
    }
}
Also used : FetchArtifactBuilder(com.thoughtworks.go.domain.builder.FetchArtifactBuilder) Builder(com.thoughtworks.go.domain.builder.Builder) FetchPluggableArtifactBuilder(com.thoughtworks.go.domain.builder.FetchPluggableArtifactBuilder)

Aggregations

Builder (com.thoughtworks.go.domain.builder.Builder)36 CommandBuilder (com.thoughtworks.go.domain.builder.CommandBuilder)13 Test (org.junit.Test)12 BuildCause (com.thoughtworks.go.domain.buildcause.BuildCause)9 NullBuilder (com.thoughtworks.go.domain.builder.NullBuilder)8 EnvironmentVariableContext (com.thoughtworks.go.util.command.EnvironmentVariableContext)6 File (java.io.File)6 ArrayList (java.util.ArrayList)6 Pipeline (com.thoughtworks.go.domain.Pipeline)5 TasksTest (com.thoughtworks.go.domain.TasksTest)5 FetchArtifactBuilder (com.thoughtworks.go.domain.builder.FetchArtifactBuilder)5 ArtifactStores (com.thoughtworks.go.config.ArtifactStores)4 PluggableTaskBuilder (com.thoughtworks.go.domain.builder.pluggableTask.PluggableTaskBuilder)4 ExecTask (com.thoughtworks.go.config.ExecTask)3 FetchPluggableArtifactBuilder (com.thoughtworks.go.domain.builder.FetchPluggableArtifactBuilder)3 JobResult (com.thoughtworks.go.domain.JobResult)2 RunIfConfigs (com.thoughtworks.go.domain.RunIfConfigs)2 StubGoPublisher (com.thoughtworks.go.domain.StubGoPublisher)2 StubBuilder (com.thoughtworks.go.domain.builder.StubBuilder)2 BuildWork (com.thoughtworks.go.remote.work.BuildWork)2