Search in sources :

Example 16 with Builder

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

the class BuildWorkTest method getWork.

private static Work getWork(String jobXml, String pipelineName, boolean fetchMaterials, boolean cleanWorkingDir) throws Exception {
    CruiseConfig cruiseConfig = new MagicalGoConfigXmlLoader(new ConfigCache(), ConfigElementImplementationRegistryMother.withNoPlugins()).loadConfigHolder(withJob(jobXml, pipelineName)).config;
    JobConfig jobConfig = cruiseConfig.jobConfigByName(pipelineName, STAGE_NAME, JOB_PLAN_NAME, true);
    JobPlan jobPlan = JobInstanceMother.createJobPlan(jobConfig, new JobIdentifier(pipelineName, -2, PIPELINE_LABEL, STAGE_NAME, String.valueOf(STAGE_COUNTER), JOB_PLAN_NAME, 0L), new DefaultSchedulingContext());
    jobPlan.setFetchMaterials(fetchMaterials);
    jobPlan.setCleanWorkingDir(cleanWorkingDir);
    final Stage stage = StageMother.custom(STAGE_NAME, new JobInstance(JOB_PLAN_NAME));
    BuildCause buildCause = BuildCause.createWithEmptyModifications();
    final Pipeline pipeline = new Pipeline(pipelineName, buildCause, stage);
    pipeline.setLabel(PIPELINE_LABEL);
    List<Builder> builder = builderFactory.buildersForTasks(pipeline, jobConfig.getTasks(), resolver);
    BuildAssignment buildAssignment = BuildAssignment.create(jobPlan, BuildCause.createWithEmptyModifications(), builder, pipeline.defaultWorkingFolder(), null, cruiseConfig.getArtifactStores());
    return new BuildWork(buildAssignment, "utf-8");
}
Also used : Builder(com.thoughtworks.go.domain.builder.Builder) BuildCause(com.thoughtworks.go.domain.buildcause.BuildCause)

Example 17 with Builder

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

the class BuilderFactoryIntegrationTest method shouldCreateBuilderForFetchPluggableArtifactTask.

@Test
public void shouldCreateBuilderForFetchPluggableArtifactTask() {
    final PipelineConfig pipelineConfig = goConfigService.pipelineConfigNamed(new CaseInsensitiveString("up42"));
    goConfigService.artifactStores().add(new ArtifactStore("storeId", "PluginId"));
    pipelineConfig.getStage("up42_stage").jobConfigByConfigName("up42_job").artifactConfigs().add(new PluggableArtifactConfig("artifactId", "storeId"));
    final FetchPluggableArtifactTask pluggableArtifactTask = new FetchPluggableArtifactTask(new CaseInsensitiveString("up42"), new CaseInsensitiveString("up42_stage"), new CaseInsensitiveString("up42_job"), "artifactId");
    final Pipeline pipeline = new Pipeline("up42", BuildCause.createExternal());
    final Builder builder = builderFactory.builderFor(pluggableArtifactTask, pipeline, upstreamResolver);
    assertThat(builder, instanceOf(FetchPluggableArtifactBuilder.class));
}
Also used : FetchArtifactBuilder(com.thoughtworks.go.domain.builder.FetchArtifactBuilder) Builder(com.thoughtworks.go.domain.builder.Builder) FetchPluggableArtifactBuilder(com.thoughtworks.go.domain.builder.FetchPluggableArtifactBuilder) FetchPluggableArtifactBuilder(com.thoughtworks.go.domain.builder.FetchPluggableArtifactBuilder) Pipeline(com.thoughtworks.go.domain.Pipeline) Test(org.junit.Test)

Example 18 with Builder

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

the class BuilderMother method createBuildersAssumingAllExecTasks.

public static List<Builder> createBuildersAssumingAllExecTasks(CruiseConfig config, String pipelineName, String stageName, String jobName) {
    Tasks tasks = config.jobConfigByName(pipelineName, stageName, jobName, true).getTasks();
    ArrayList<Builder> builders = new ArrayList<>();
    for (Task task : tasks) {
        builders.add(builderFor((ExecTask) task));
    }
    return builders;
}
Also used : ExecTask(com.thoughtworks.go.config.ExecTask) Task(com.thoughtworks.go.domain.Task) Tasks(com.thoughtworks.go.config.Tasks) Builder(com.thoughtworks.go.domain.builder.Builder) ExecTask(com.thoughtworks.go.config.ExecTask) ArrayList(java.util.ArrayList)

Example 19 with Builder

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

the class JobRunnerTest method getWork.

private BuildWork getWork(JobConfig jobConfig) {
    CruiseConfig config = new BasicCruiseConfig();
    config.server().setArtifactsDir("logs");
    String stageName = "mingle";
    String pipelineName = "pipeline1";
    config.addPipeline(BasicPipelineConfigs.DEFAULT_GROUP, new PipelineConfig(new CaseInsensitiveString(pipelineName), new MaterialConfigs(), new StageConfig(new CaseInsensitiveString(stageName), new JobConfigs(jobConfig))));
    String pipelineLabel = "100";
    JobPlan jobPlan = JobInstanceMother.createJobPlan(jobConfig, new JobIdentifier(pipelineName, -2, pipelineLabel, stageName, "100", JOB_PLAN_NAME, 0L), new DefaultSchedulingContext());
    jobPlan.setFetchMaterials(true);
    jobPlan.setCleanWorkingDir(false);
    List<Builder> builder = BuilderMother.createBuildersAssumingAllExecTasks(config, pipelineName, stageName, JOB_PLAN_NAME);
    BuildAssignment buildAssignment = BuildAssignment.create(jobPlan, BuildCause.createWithEmptyModifications(), builder, new File(CruiseConfig.WORKING_BASE_DIR + pipelineName));
    return new BuildWork(buildAssignment);
}
Also used : MaterialConfigs(com.thoughtworks.go.config.materials.MaterialConfigs) Builder(com.thoughtworks.go.domain.builder.Builder) BuildAssignment(com.thoughtworks.go.remote.work.BuildAssignment) BuildWork(com.thoughtworks.go.remote.work.BuildWork) File(java.io.File)

Example 20 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, FetchTask task, Pipeline pipeline, UpstreamPipelineResolver resolver) {
    JobIdentifier fetchFrom = resolveTargetJob(task, pipeline, resolver);
    Builder cancelBuilder = builderFactory.builderFor(task.cancelTask(), pipeline, resolver);
    return new FetchArtifactBuilder(task.getConditions(), cancelBuilder, task.describe(), fetchFrom, task.getSrc(), task.getDest(), getHandler(task, pipeline.getName()), getChecksumHandler(task, pipeline.getName()));
}
Also used : FetchArtifactBuilder(com.thoughtworks.go.domain.builder.FetchArtifactBuilder) FetchArtifactBuilder(com.thoughtworks.go.domain.builder.FetchArtifactBuilder) Builder(com.thoughtworks.go.domain.builder.Builder) JobIdentifier(com.thoughtworks.go.domain.JobIdentifier)

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