use of com.thoughtworks.go.server.service.AgentBuildingInfo in project gocd by gocd.
the class BuildWork method initialize.
private void initialize(BuildRepositoryRemote remoteBuildRepository, GoArtifactsManipulator goArtifactsManipulator, AgentRuntimeInfo agentRuntimeInfo, TaskExtension taskExtension) {
timeProvider = new TimeProvider();
plan = assignment.getPlan();
agentRuntimeInfo.busy(new AgentBuildingInfo(plan.getIdentifier().buildLocatorForDisplay(), plan.getIdentifier().buildLocator()));
workingDirectory = assignment.getWorkingDirectory();
materialRevisions = assignment.materialRevisions();
buildLog = new GoControlLog(this.workingDirectory + "/cruise-output");
goPublisher = new DefaultGoPublisher(goArtifactsManipulator, plan.getIdentifier(), remoteBuildRepository, agentRuntimeInfo);
builders = new Builders(assignment.getBuilders(), goPublisher, buildLog, taskExtension);
}
use of com.thoughtworks.go.server.service.AgentBuildingInfo in project gocd by gocd.
the class SleepWork method doWork.
@Override
public void doWork(AgentIdentifier agentIdentifier, BuildRepositoryRemote remoteBuildRepository, GoArtifactsManipulator manipulator, EnvironmentVariableContext environmentVariableContext, AgentRuntimeInfo agentRuntimeInfo, PackageRepositoryExtension packageRepositoryExtension, SCMExtension scmExtension, TaskExtension taskExtension) {
cancelLatch = new CountDownLatch(1);
agentRuntimeInfo.busy(new AgentBuildingInfo("sleepwork", "sleepwork1"));
boolean canceled = false;
DefaultGoPublisher goPublisher = new DefaultGoPublisher(manipulator, new JobIdentifier(), remoteBuildRepository, agentRuntimeInfo);
try {
if (this.sleepInMilliSeconds > 0) {
canceled = cancelLatch.await(this.sleepInMilliSeconds, TimeUnit.MILLISECONDS);
}
String result = canceled ? "done_canceled" : "done";
manipulator.setProperty(null, new Property(name + "_result", result));
SystemEnvironment systemEnvironment = new SystemEnvironment();
if (systemEnvironment.isConsoleLogsThroughWebsocketEnabled() && systemEnvironment.isWebsocketsForAgentsEnabled()) {
goPublisher.consumeLine(format("Sleeping for %s milliseconds", this.sleepInMilliSeconds));
}
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
}
use of com.thoughtworks.go.server.service.AgentBuildingInfo in project gocd by gocd.
the class AgentStatusReportingIntegrationTest method expectedAgentRuntimeInfo.
private AgentRuntimeInfo expectedAgentRuntimeInfo() {
AgentRuntimeInfo info = new AgentRuntimeInfo(agentIdentifier, AgentRuntimeStatus.Idle, currentWorkingDirectory(), "cookie", false);
info.setBuildingInfo(new AgentBuildingInfo("pipeline1/100/mingle/100/run-ant", "pipeline1/100/mingle/100/run-ant"));
info.cancel();
return info;
}
use of com.thoughtworks.go.server.service.AgentBuildingInfo in project gocd by gocd.
the class AgentStatusReportingTest method shouldReportBuildingWhenAgentRunningBuildWork.
@Test
public void shouldReportBuildingWhenAgentRunningBuildWork() throws Exception {
Work work = BuildWorkTest.getWork(WILL_PASS, BuildWorkTest.PIPELINE_NAME);
work.doWork(environmentVariableContext, new AgentWorkContext(agentIdentifier, buildRepository, artifactManipulator, agentRuntimeInfo, null, null, null, null, null));
AgentRuntimeInfo agentRuntimeInfo1 = new AgentRuntimeInfo(agentIdentifier, AgentRuntimeStatus.Idle, currentWorkingDirectory(), "cookie", false);
agentRuntimeInfo1.busy(new AgentBuildingInfo("pipeline1/100/mingle/100/run-ant", "pipeline1/100/mingle/100/run-ant"));
assertThat(agentRuntimeInfo, is(agentRuntimeInfo1));
}
use of com.thoughtworks.go.server.service.AgentBuildingInfo in project gocd by gocd.
the class AgentInstanceMother method lostContact.
public static AgentInstance lostContact(String buildLocator) {
AgentConfig agentConfig = new AgentConfig("1234", "localhost", "192.168.0.1");
AgentInstance instance = AgentInstance.createFromConfig(agentConfig, new SystemEnvironment(), mock(AgentStatusChangeListener.class));
AgentRuntimeInfo newRuntimeInfo = AgentRuntimeInfo.initialState(agentConfig);
newRuntimeInfo.setStatus(AgentStatus.LostContact);
newRuntimeInfo.setUsableSpace(1000L);
newRuntimeInfo.setBuildingInfo(new AgentBuildingInfo("buildInfo", buildLocator));
instance.update(newRuntimeInfo);
return instance;
}
Aggregations