use of com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModels in project gocd by gocd.
the class GoDashboardCurrentStateLoader method findPIMsWithFallbacks.
private PipelineInstanceModels findPIMsWithFallbacks(PipelineConfig pipelineConfig, PipelineInstanceModels historyForDashboard) {
String pipelineName = str(pipelineConfig.name());
PipelineInstanceModels pipelinesToShow = historyForDashboard.findAll(pipelineName);
if (!pipelinesToShow.isEmpty()) {
return pipelinesToShow;
}
if (triggerMonitor.isAlreadyTriggered(pipelineConfig.name())) {
return createPipelineInstanceModels(createPreparingToSchedule(pipelineName, new StageInstanceModels()));
}
return createPipelineInstanceModels(createEmptyPipelineInstanceModel(pipelineName, createWithEmptyModifications(), new StageInstanceModels()));
}
use of com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModels in project gocd by gocd.
the class PipelineSqlMapDaoIntegrationTest method shouldReturnLatestPipelineHistory.
@Test
public void shouldReturnLatestPipelineHistory() throws SQLException {
String pipelineName = "some-pipeline";
PipelineConfig pipelineConfig = PipelineMother.twoBuildPlansWithResourcesAndMaterials(pipelineName, "dev", "ft");
Pipeline pipeline1 = dbHelper.newPipelineWithAllStagesPassed(pipelineConfig);
Pipeline pipeline2 = dbHelper.newPipelineWithAllStagesPassed(pipelineConfig);
Pipeline pipeline3 = dbHelper.newPipelineWithAllStagesPassed(pipelineConfig);
Pipeline pipeline4 = dbHelper.newPipelineWithAllStagesPassed(pipelineConfig);
Pipeline pipeline5 = dbHelper.newPipelineWithAllStagesPassed(pipelineConfig);
List<CaseInsensitiveString> allPipelineNames = goConfigDao.load().getAllPipelineNames();
if (!allPipelineNames.contains(new CaseInsensitiveString("twist"))) {
goConfigDao.addPipeline(pipelineConfig, "pipelinesqlmapdaotest");
}
PipelineInstanceModels pipelineInstanceModels = pipelineDao.loadHistory(pipelineName, FeedModifier.Latest, 0, 3);
assertThat(pipelineInstanceModels.size(), is(3));
assertThat(pipelineInstanceModels.get(0).getId(), is(pipeline5.getId()));
assertThat(pipelineInstanceModels.get(1).getId(), is(pipeline4.getId()));
assertThat(pipelineInstanceModels.get(2).getId(), is(pipeline3.getId()));
}
use of com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModels in project gocd by gocd.
the class PipelineSqlMapDaoIntegrationTest method shouldLoadPipelineHistories.
@Test
public void shouldLoadPipelineHistories() throws Exception {
String dev = "dev";
PipelineConfig mingleConfig = PipelineMother.twoBuildPlansWithResourcesAndMaterials("mingle", dev);
Pipeline mingle = schedulePipelineWithStages(mingleConfig);
Stage firstStage = mingle.getFirstStage();
Pipeline mingle2 = schedulePipelineWithStages(mingleConfig);
JobInstance instance = firstStage.getJobInstances().first();
jobInstanceDao.ignore(instance);
PipelineInstanceModels pipelineHistories = pipelineDao.loadHistory(mingle.getName(), 10, 0);
assertThat(pipelineHistories.size(), is(2));
StageInstanceModels stageHistories = pipelineHistories.first().getStageHistory();
assertThat(stageHistories.size(), is(1));
StageInstanceModel history = stageHistories.first();
assertThat(history.getName(), is(dev));
assertThat(history.getApprovalType(), is(GoConstants.APPROVAL_SUCCESS));
assertThat(history.getBuildHistory().size(), is(2));
assertThat(pipelineHistories.get(1).getName(), is("mingle"));
}
use of com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModels in project gocd by gocd.
the class InternalCompareControllerV2 method list.
String list(Request request, Response response) throws IOException {
String pipelineName = request.params("pipeline_name");
Integer pageSize = getPageSize(request);
String pattern = request.queryParamOrDefault("pattern", "");
HttpLocalizedOperationResult result = new HttpLocalizedOperationResult();
PipelineInstanceModels pipelineInstanceModels = pipelineHistoryService.findMatchingPipelineInstances(pipelineName, pattern, pageSize, currentUsername(), result);
if (result.isSuccessful()) {
return writerForTopLevelObject(request, response, outputWriter -> PipelineInstanceModelsRepresenter.toJSON(outputWriter, pipelineInstanceModels));
} else {
return renderHTTPOperationResult(result, request, response);
}
}
use of com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModels in project gocd by gocd.
the class PipelineInstanceControllerV1 method getHistoryInfo.
String getHistoryInfo(Request request, Response response) throws IOException {
String pipelineName = request.params("pipeline_name");
Integer pageSize = getPageSize(request);
Long after = getCursor(request, "after");
Long before = getCursor(request, "before");
PipelineInstanceModels pipelineInstanceModels = pipelineHistoryService.loadPipelineHistoryData(currentUsername(), pipelineName, after, before, pageSize);
PipelineRunIdInfo latestAndOldestPipelineIds = pipelineHistoryService.getOldestAndLatestPipelineId(pipelineName, currentUsername());
return writerForTopLevelObject(request, response, (outputWriter) -> PipelineInstanceModelsRepresenter.toJSON(outputWriter, pipelineInstanceModels, latestAndOldestPipelineIds));
}
Aggregations