Search in sources :

Example 56 with JobInstance

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;
}
Also used : FolderDirectoryEntry(com.thoughtworks.go.domain.FolderDirectoryEntry) DirectoryEntries(com.thoughtworks.go.domain.DirectoryEntries) JobInstance(com.thoughtworks.go.domain.JobInstance) DirectoryReader(com.thoughtworks.go.util.DirectoryReader) JobInstances(com.thoughtworks.go.domain.JobInstances)

Example 57 with JobInstance

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;
}
Also used : JobInstance(com.thoughtworks.go.domain.JobInstance) JobIdentifier(com.thoughtworks.go.domain.JobIdentifier) JobInstances(com.thoughtworks.go.domain.JobInstances) LinkedHashMap(java.util.LinkedHashMap)

Example 58 with JobInstance

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;
}
Also used : JobInstance(com.thoughtworks.go.domain.JobInstance) Stage(com.thoughtworks.go.domain.Stage) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Pipeline(com.thoughtworks.go.domain.Pipeline)

Example 59 with JobInstance

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);
}
Also used : Agent(com.thoughtworks.go.server.domain.Agent) JobInstance(com.thoughtworks.go.domain.JobInstance) JobInstanceModel(com.thoughtworks.go.server.ui.JobInstanceModel) JobInstances(com.thoughtworks.go.domain.JobInstances) Test(org.junit.Test)

Example 60 with JobInstance

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));
}
Also used : DirectoryEntries(com.thoughtworks.go.domain.DirectoryEntries) JobInstance(com.thoughtworks.go.domain.JobInstance) Stage(com.thoughtworks.go.domain.Stage) File(java.io.File) Test(org.junit.Test)

Aggregations

JobInstance (com.thoughtworks.go.domain.JobInstance)82 Test (org.junit.Test)56 Stage (com.thoughtworks.go.domain.Stage)16 JobIdentifier (com.thoughtworks.go.domain.JobIdentifier)15 Pipeline (com.thoughtworks.go.domain.Pipeline)15 JobInstances (com.thoughtworks.go.domain.JobInstances)12 JobConfigIdentifier (com.thoughtworks.go.domain.JobConfigIdentifier)7 Agent (com.thoughtworks.go.server.domain.Agent)6 Gson (com.google.gson.Gson)5 Stages (com.thoughtworks.go.domain.Stages)5 Map (java.util.Map)5 DurationBean (com.thoughtworks.go.dto.DurationBean)4 DateTime (org.joda.time.DateTime)4 ArtifactPropertiesGenerator (com.thoughtworks.go.config.ArtifactPropertiesGenerator)3 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)3 Resource (com.thoughtworks.go.config.Resource)3 DirectoryEntries (com.thoughtworks.go.domain.DirectoryEntries)3 StageIdentifier (com.thoughtworks.go.domain.StageIdentifier)3 ProjectStatus (com.thoughtworks.go.domain.activity.ProjectStatus)3 JobInstanceModel (com.thoughtworks.go.server.ui.JobInstanceModel)3