use of com.thoughtworks.go.domain.builder.NullBuilder in project gocd by gocd.
the class Builders method build.
public JobResult build(EnvironmentVariableContext environmentVariableContext) {
JobResult result = JobResult.Passed;
for (Builder builder : builders) {
if (cancelStarted) {
return JobResult.Cancelled;
}
synchronized (this) {
currentBuilder = builder;
}
BuildLogElement buildLogElement = new BuildLogElement();
try {
builder.build(buildLogElement, RunIfConfig.fromJobResult(result.toLowerCase()), goPublisher, environmentVariableContext, taskExtension);
} catch (Exception e) {
result = JobResult.Failed;
}
buildLog.addContent(buildLogElement.getElement());
}
synchronized (this) {
currentBuilder = new NullBuilder();
}
if (cancelStarted) {
return JobResult.Cancelled;
}
return result;
}
use of com.thoughtworks.go.domain.builder.NullBuilder in project gocd by gocd.
the class Builders method build.
public JobResult build(EnvironmentVariableContext environmentVariableContext, String consoleLogCharset) {
JobResult result = JobResult.Passed;
for (Builder builder : builders) {
if (cancelStarted) {
return JobResult.Cancelled;
}
synchronized (this) {
currentBuilder = builder;
}
if (builder.allowRun(RunIfConfig.fromJobResult(result.toLowerCase()))) {
JobResult taskStatus = JobResult.Passed;
Instant start = Instant.now();
try {
String executeMessage = format("Task: %s", builder.getDescription());
goPublisher.taggedConsumeLineWithPrefix(DefaultGoPublisher.TASK_START, executeMessage);
builder.build(goPublisher, environmentVariableContext, taskExtension, artifactExtension, pluginRequestProcessorRegistry, consoleLogCharset);
} catch (Exception e) {
result = taskStatus = JobResult.Failed;
}
Duration duration = Duration.between(start, Instant.now());
String statusLine = format("Task status: %s (%d ms)", taskStatus.toLowerCase(), duration.toMillis());
if (cancelStarted) {
result = taskStatus = JobResult.Cancelled;
}
String tag;
if (taskStatus.isPassed()) {
tag = DefaultGoPublisher.TASK_PASS;
} else {
if (Builder.UNSET_EXIT_CODE != builder.getExitCode()) {
statusLine = format("%s (exit code: %d)", statusLine, builder.getExitCode());
}
tag = taskStatus.isCancelled() ? DefaultGoPublisher.TASK_CANCELLED : DefaultGoPublisher.TASK_FAIL;
}
goPublisher.taggedConsumeLineWithPrefix(tag, statusLine);
}
}
synchronized (this) {
currentBuilder = new NullBuilder();
}
if (cancelStarted) {
return JobResult.Cancelled;
}
return result;
}
use of com.thoughtworks.go.domain.builder.NullBuilder in project gocd by gocd.
the class BuildAssignmentTest method createAssignment.
private BuildAssignment createAssignment(EnvironmentVariableContext environmentVariableContext, BuildCause buildCause) {
JobPlan plan = new DefaultJobPlan(new Resources(), new ArrayList<>(), -1, new JobIdentifier(PIPELINE_NAME, 1, "1", STAGE_NAME, "1", JOB_NAME, 123L), null, new EnvironmentVariables(), new EnvironmentVariables(), null, null);
List<Builder> builders = new ArrayList<>();
builders.add(new CommandBuilder("ls", "", null, new RunIfConfigs(), new NullBuilder(), ""));
return BuildAssignment.create(plan, buildCause, builders, null, environmentVariableContext, new ArtifactStores());
}
use of com.thoughtworks.go.domain.builder.NullBuilder 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);
}
use of com.thoughtworks.go.domain.builder.NullBuilder 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());
}
Aggregations