use of com.thoughtworks.go.domain.builder.Builder 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());
}
use of com.thoughtworks.go.domain.builder.Builder in project gocd by gocd.
the class BuildAssignmentService method createWork.
private Work createWork(final AgentInstance agent, final JobPlan job) {
try {
return (Work) transactionTemplate.transactionSurrounding(new TransactionTemplate.TransactionSurrounding<RuntimeException>() {
public Object surrounding() {
final String agentUuid = agent.getUuid();
// TODO: Use fullPipeline and get the Stage from it?
final Pipeline pipeline;
try {
pipeline = scheduledPipelineLoader.pipelineWithPasswordAwareBuildCauseByBuildId(job.getJobId());
} catch (StaleMaterialsOnBuildCause e) {
return NO_WORK;
}
List<Task> tasks = goConfigService.tasksForJob(pipeline.getName(), job.getIdentifier().getStageName(), job.getName());
final List<Builder> builders = builderFactory.buildersForTasks(pipeline, tasks, resolver);
return transactionTemplate.execute(new TransactionCallback() {
public Object doInTransaction(TransactionStatus status) {
if (scheduleService.updateAssignedInfo(agentUuid, job)) {
return NO_WORK;
}
EnvironmentVariableContext contextFromEnvironment = environmentConfigService.environmentVariableContextFor(job.getIdentifier().getPipelineName());
final ArtifactStores requiredArtifactStores = goConfigService.artifactStores().getArtifactStores(getArtifactStoreIdsRequiredByArtifactPlans(job.getArtifactPlans()));
BuildAssignment buildAssignment = BuildAssignment.create(job, pipeline.getBuildCause(), builders, pipeline.defaultWorkingFolder(), contextFromEnvironment, requiredArtifactStores);
return new BuildWork(buildAssignment, systemEnvironment.consoleLogCharset());
}
});
}
});
} catch (PipelineNotFoundException e) {
removeJobIfNotPresentInCruiseConfig(goConfigService.getCurrentConfig(), job);
throw e;
}
}
use of com.thoughtworks.go.domain.builder.Builder 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");
}
use of com.thoughtworks.go.domain.builder.Builder 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());
}
use of com.thoughtworks.go.domain.builder.Builder in project gocd by gocd.
the class BuilderFactoryIntegrationTest method shouldCreateBuilderForFetchTask.
@Test
public void shouldCreateBuilderForFetchTask() {
final FetchTask fetchTask = new FetchTask(new CaseInsensitiveString("up42"), new CaseInsensitiveString("up42_stage"), new CaseInsensitiveString("up42_job"), "installers.zip", "dist");
final Pipeline pipeline = new Pipeline("up42", BuildCause.createExternal());
final Builder builder = builderFactory.builderFor(fetchTask, pipeline, upstreamResolver);
assertThat(builder, instanceOf(FetchArtifactBuilder.class));
}
Aggregations