Search in sources :

Example 46 with PipelineInstanceModels

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()));
}
Also used : PipelineInstanceModels(com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModels) PipelineInstanceModels.createPipelineInstanceModels(com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModels.createPipelineInstanceModels) StageInstanceModels(com.thoughtworks.go.presentation.pipelinehistory.StageInstanceModels)

Example 47 with PipelineInstanceModels

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()));
}
Also used : PipelineConfig(com.thoughtworks.go.config.PipelineConfig) PipelineInstanceModels(com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModels) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Test(org.junit.jupiter.api.Test)

Example 48 with PipelineInstanceModels

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"));
}
Also used : PipelineConfig(com.thoughtworks.go.config.PipelineConfig) PipelineInstanceModels(com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModels) StageInstanceModels(com.thoughtworks.go.presentation.pipelinehistory.StageInstanceModels) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) StageInstanceModel(com.thoughtworks.go.presentation.pipelinehistory.StageInstanceModel) Test(org.junit.jupiter.api.Test)

Example 49 with PipelineInstanceModels

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);
    }
}
Also used : HttpLocalizedOperationResult(com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult) PipelineInstanceModels(com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModels)

Example 50 with PipelineInstanceModels

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));
}
Also used : PipelineRunIdInfo(com.thoughtworks.go.domain.PipelineRunIdInfo) PipelineInstanceModels(com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModels)

Aggregations

PipelineInstanceModels (com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModels)50 Test (org.junit.Test)20 Test (org.junit.jupiter.api.Test)20 PipelineConfig (com.thoughtworks.go.config.PipelineConfig)14 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)12 PipelineInstanceModel (com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModel)10 StageInstanceModels (com.thoughtworks.go.presentation.pipelinehistory.StageInstanceModels)8 PipelineInstanceModels.createPipelineInstanceModels (com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModels.createPipelineInstanceModels)5 StageInstanceModel (com.thoughtworks.go.presentation.pipelinehistory.StageInstanceModel)4 PipelineHistoryGroups (com.thoughtworks.go.server.presentation.models.PipelineHistoryGroups)4 EmptyPipelineInstanceModel (com.thoughtworks.go.presentation.pipelinehistory.EmptyPipelineInstanceModel)3 Document (org.dom4j.Document)3 XmlWriterContext (com.thoughtworks.go.domain.XmlWriterContext)2 HttpLocalizedOperationResult (com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult)2 SystemEnvironment (com.thoughtworks.go.util.SystemEnvironment)2 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)2 PipelineNotFoundException (com.thoughtworks.go.config.PipelineNotFoundException)1 StageConfig (com.thoughtworks.go.config.StageConfig)1 DependencyMaterial (com.thoughtworks.go.config.materials.dependency.DependencyMaterial)1 HgMaterial (com.thoughtworks.go.config.materials.mercurial.HgMaterial)1