use of com.thoughtworks.go.domain.JobInstance in project gocd by gocd.
the class StageDetailPresentationModel method getArtifactFiles.
public DirectoryEntries getArtifactFiles() throws IllegalArtifactLocationException {
JobInstances withNonEmptyArtifacts = stage.getJobInstances();
DirectoryEntries artifacts = new DirectoryEntries();
for (JobInstance instance : withNonEmptyArtifacts) {
DirectoryReader directoryReader = new DirectoryReader(instance.getIdentifier());
DirectoryEntries subDirectories = directoryReader.listEntries(artifactsService.findArtifact(instance.getIdentifier(), ""), "");
artifacts.add(new FolderDirectoryEntry(instance.getName(), "", subDirectories));
}
return artifacts;
}
use of com.thoughtworks.go.domain.JobInstance in project gocd by gocd.
the class StageDetailPresentationModel method getIndexPages.
public Map<JobInstance, String> getIndexPages() {
JobInstances nonEmptyIndexPages = stage.getJobInstances().withNonEmptyIndexPages();
Map<JobInstance, String> aggregate = new LinkedHashMap<>();
for (JobInstance job : nonEmptyIndexPages) {
JobIdentifier jobIdentifier = new JobIdentifier(pipeline.getName(), pipeline.getCounter(), pipeline.getLabel(), stage.getName(), String.valueOf(stage.getCounter()), job.getName(), job.getId());
String filePath = job.getTestIndexPage().getPath();
String path = FileUtil.normalizePath(filePath.substring(filePath.indexOf(TEST_OUTPUT_FOLDER)));
aggregate.put(job, baseArtifactUrl(jobIdentifier, path));
}
return aggregate;
}
use of com.thoughtworks.go.domain.JobInstance in project gocd by gocd.
the class StageIntegrationTest method createPipelineWithFirstStageCompletedAndNextStageBuilding.
private Stage createPipelineWithFirstStageCompletedAndNextStageBuilding(StageState stageState) throws Exception {
Pipeline newPipeline = createPipelineWithFirstStageBuilding();
Stage mostRecent = newPipeline.getFirstStage();
JobInstance job = mostRecent.getJobInstances().first();
if (stageState.equals(StageState.Failed)) {
dbHelper.failStage(mostRecent);
} else {
dbHelper.passStage(mostRecent);
}
buildRepositoryService.updateStatusFromAgent(getBuildIdentifier(job.getId()), JobState.Completed, AGENT_UUID);
Stage nextStage = stageDao.mostRecentWithBuilds(PIPELINE_NAME, mingle.findBy(new CaseInsensitiveString(FT_STAGE)));
dbHelper.buildingBuildInstance(nextStage);
return nextStage;
}
use of com.thoughtworks.go.domain.JobInstance in project gocd by gocd.
the class JobPresentationServiceTest method shouldReturnJobModelForAnAgentThatIsNoMoreAvailableInTheConfig.
@Test
public void shouldReturnJobModelForAnAgentThatIsNoMoreAvailableInTheConfig() throws Exception {
String deletedAgentUuid = "deleted_agent";
JobInstance jobWithDeletedAgent = assignedWithAgentId("dev", deletedAgentUuid);
when(agentService.findAgentAndRefreshStatus(deletedAgentUuid)).thenReturn(null);
Agent agentFromDb = new Agent(deletedAgentUuid, "cookie", "hostname", "1.2.3.4");
when(agentService.findAgentObjectByUuid(deletedAgentUuid)).thenReturn(agentFromDb);
List<JobInstanceModel> models = new JobPresentationService(jobDurationStrategy, agentService).jobInstanceModelFor(new JobInstances(jobWithDeletedAgent));
assertThat(models.size(), is(1));
assertThat(models.get(0), is(new JobInstanceModel(jobWithDeletedAgent, jobDurationStrategy, agentFromDb)));
verify(agentService, times(1)).findAgentAndRefreshStatus(deletedAgentUuid);
verify(agentService, times(1)).findAgentObjectByUuid(deletedAgentUuid);
verifyNoMoreInteractions(agentService);
}
use of com.thoughtworks.go.domain.JobInstance in project gocd by gocd.
the class JobDetailPresentationModelTest method shouldShowMessage.
@Test
public void shouldShowMessage() throws IllegalArtifactLocationException {
JobInstance jobInstance = JobInstanceMother.completed("job-1");
Stage stage = new Stage();
stage.setArtifactsDeleted(true);
DirectoryEntries directoryEntries = new DirectoryEntries();
when(directoryReader.listEntries(any(File.class), any(String.class))).thenReturn(directoryEntries);
JobDetailPresentationModel jobDetailPresentationModel = new JobDetailPresentationModel(jobInstance, null, null, null, null, null, artifactsService, null, stage);
DirectoryEntries artifactFiles = jobDetailPresentationModel.getArtifactFiles(directoryReader);
assertThat(artifactFiles.isArtifactsDeleted(), is(true));
}
Aggregations