Search in sources :

Example 1 with Properties

use of com.thoughtworks.go.domain.Properties in project gocd by gocd.

the class JobController method presenter.

private JobDetailPresentationModel presenter(JobInstance current) {
    String pipelineName = current.getIdentifier().getPipelineName();
    String stageName = current.getIdentifier().getStageName();
    JobInstances recent25 = jobInstanceService.latestCompletedJobs(pipelineName, stageName, current.getName());
    AgentConfig agentConfig = goConfigService.agentByUuid(current.getAgentUuid());
    Pipeline pipelineWithOneBuild = pipelineService.wrapBuildDetails(current);
    Tabs customizedTabs = goConfigService.getCustomizedTabs(pipelineWithOneBuild.getName(), pipelineWithOneBuild.getFirstStage().getName(), current.getName());
    TrackingTool trackingTool = goConfigService.pipelineConfigNamed(new CaseInsensitiveString(pipelineWithOneBuild.getName())).trackingTool();
    Properties properties = propertiesService.getPropertiesForJob(current.getId());
    Stage stage = stageService.getStageByBuild(current);
    return new JobDetailPresentationModel(current, recent25, agentConfig, pipelineWithOneBuild, customizedTabs, trackingTool, artifactService, properties, stage);
}
Also used : JobDetailPresentationModel(com.thoughtworks.go.server.presentation.models.JobDetailPresentationModel) Properties(com.thoughtworks.go.domain.Properties)

Example 2 with Properties

use of com.thoughtworks.go.domain.Properties in project gocd by gocd.

the class PropertiesController method jobsSearch.

@RequestMapping("/repository/restful/properties/jobs/search")
public ModelAndView jobsSearch(@RequestParam("pipelineName") String pipelineName, @RequestParam("stageName") String stageName, @RequestParam("jobName") String jobName, @RequestParam(value = "limitPipeline", required = false) String limitPipeline, @RequestParam(value = "limitCount", required = false) Integer limitCount, HttpServletResponse response) throws Exception {
    Long limitPipelineId = null;
    if (limitPipeline != null) {
        Pipeline pipeline = pipelineService.findPipelineByCounterOrLabel(pipelineName, limitPipeline);
        if (pipeline != null) {
            limitPipelineId = pipeline.getId();
        } else {
            return notFound(String.format("The value [%s] of query parameter 'limitPipeline' is neither a pipeline counter nor label", limitPipeline)).respond(response);
        }
    }
    limitCount = limitCount == null ? 100 : limitCount;
    try {
        List<Properties> result = propertyService.loadHistory(pipelineName, stageName, jobName, limitPipelineId, limitCount);
        PropertiesService.PropertyLister propertyLister = PropertiesService.asCsv(jobName);
        return propertyLister.listPropertiesHistory(result).respond(response);
    } catch (Exception e) {
        String message = String.format("Error on listing properties history for job %s/%s/%s with limitPipeline=%s and limitCount=%s", pipelineName, stageName, jobName, limitPipeline, limitCount);
        LOGGER.error(message, e);
        return notFound(message + "\n" + e.getMessage()).respond(response);
    }
}
Also used : PropertiesService(com.thoughtworks.go.server.service.PropertiesService) Properties(com.thoughtworks.go.domain.Properties) Pipeline(com.thoughtworks.go.domain.Pipeline) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 3 with Properties

use of com.thoughtworks.go.domain.Properties in project gocd by gocd.

the class PropertyDaoTest method shouldLoadAllPropertiesHistoryIfLimitPipelineNotSpecified.

@Test
public void shouldLoadAllPropertiesHistoryIfLimitPipelineNotSpecified() throws Exception {
    Pipeline oldPipeline = createPipelineWithJobProperty(PIPELINE1, property("key1", "value1"));
    Pipeline newPipeline = createPipelineWithJobProperty(PIPELINE1, property("key2", "value2"));
    List<Properties> history = propertyDao.loadHistory(PIPELINE1, STAGE1, PLAN1, null, Integer.MAX_VALUE);
    assertThat(history.size(), is(2));
}
Also used : Properties(com.thoughtworks.go.domain.Properties) Pipeline(com.thoughtworks.go.domain.Pipeline) Test(org.junit.Test)

Example 4 with Properties

use of com.thoughtworks.go.domain.Properties in project gocd by gocd.

the class PropertyDaoTest method shouldReturnListOfAllProperties.

@Test
public void shouldReturnListOfAllProperties() throws Exception {
    Property propertyB = property("a/2", "d");
    Property propertyA = property("a/1", "b");
    propertyDao.save(buildId, propertyB);
    propertyDao.save(buildId, propertyA);
    Properties properties = propertyDao.list(buildId);
    assertThat(properties.size(), is(2));
    assertThat(properties.get(0), is(propertyA));
    assertThat(properties.get(1), is(propertyB));
}
Also used : Properties(com.thoughtworks.go.domain.Properties) Property(com.thoughtworks.go.domain.Property) Test(org.junit.Test)

Example 5 with Properties

use of com.thoughtworks.go.domain.Properties in project gocd by gocd.

the class PropertiesServiceTest method shouldReturnEmptyListIfLimitCountIsNotPositive.

@Test
public void shouldReturnEmptyListIfLimitCountIsNotPositive() {
    Pipeline pipeline1 = createNewPipeline();
    Pipeline pipeline2 = createNewPipeline();
    List<Properties> propertiesList = propertiesService.loadHistory(fixture.pipelineName, fixture.devStage, PipelineWithTwoStages.JOB_FOR_DEV_STAGE, pipeline2.getId(), -1);
    assertThat(propertiesList.size(), is(0));
    propertiesList = propertiesService.loadHistory(fixture.pipelineName, fixture.devStage, PipelineWithTwoStages.JOB_FOR_DEV_STAGE, pipeline2.getId(), 0);
    assertThat(propertiesList.size(), is(0));
}
Also used : Properties(com.thoughtworks.go.domain.Properties) Pipeline(com.thoughtworks.go.domain.Pipeline) Test(org.junit.Test)

Aggregations

Properties (com.thoughtworks.go.domain.Properties)13 Test (org.junit.Test)8 Property (com.thoughtworks.go.domain.Property)6 Pipeline (com.thoughtworks.go.domain.Pipeline)5 Csv (com.thoughtworks.go.util.Csv)2 JobIdentifier (com.thoughtworks.go.domain.JobIdentifier)1 JobPlan (com.thoughtworks.go.domain.JobPlan)1 XmlWriterContext (com.thoughtworks.go.domain.XmlWriterContext)1 PropertyDao (com.thoughtworks.go.server.dao.PropertyDao)1 JobDetailPresentationModel (com.thoughtworks.go.server.presentation.models.JobDetailPresentationModel)1 PropertiesService (com.thoughtworks.go.server.service.PropertiesService)1 ArrayList (java.util.ArrayList)1 Before (org.junit.Before)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1