Search in sources :

Example 1 with PipelineIdentifier

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

the class RestfulService method findJob.

/**
 * buildId should only be given when caller is absolutely sure about the job instance
 * (makes sense in agent-uploading artifacts/properties scenario because agent won't run a job if its copied over(it only executes real jobs)) -JJ
 * <p>
 * This does not return pipelineLabel
 */
public JobIdentifier findJob(String pipelineName, String pipelineCounter, String stageName, String stageCounter, String buildName, Long buildId) {
    JobConfigIdentifier jobConfigIdentifier = goConfigService.translateToActualCase(new JobConfigIdentifier(pipelineName, stageName, buildName));
    PipelineIdentifier pipelineIdentifier;
    if (JobIdentifier.LATEST.equalsIgnoreCase(pipelineCounter)) {
        pipelineIdentifier = pipelineService.mostRecentPipelineIdentifier(jobConfigIdentifier.getPipelineName());
    } else if (StringUtils.isNumeric(pipelineCounter)) {
        pipelineIdentifier = pipelineService.findPipelineByNameAndCounter(pipelineName, Integer.parseInt(pipelineCounter)).getIdentifier();
    } else {
        throw new RuntimeException("Expected numeric pipeline counter but received '%s'" + pipelineCounter);
    }
    stageCounter = StringUtils.isEmpty(stageCounter) ? JobIdentifier.LATEST : stageCounter;
    StageIdentifier stageIdentifier = translateStageCounter(pipelineIdentifier, jobConfigIdentifier.getStageName(), stageCounter);
    JobIdentifier jobId;
    if (buildId == null) {
        jobId = jobResolverService.actualJobIdentifier(new JobIdentifier(stageIdentifier, jobConfigIdentifier.getJobName()));
    } else {
        jobId = new JobIdentifier(stageIdentifier, jobConfigIdentifier.getJobName(), buildId);
    }
    if (jobId == null) {
        // fix for #5739
        throw new RecordNotFoundException(String.format("Job '%s' not found in pipeline '%s' stage '%s'", buildName, pipelineName, stageName));
    }
    return jobId;
}
Also used : StageIdentifier(com.thoughtworks.go.domain.StageIdentifier) RecordNotFoundException(com.thoughtworks.go.config.exceptions.RecordNotFoundException) PipelineIdentifier(com.thoughtworks.go.domain.PipelineIdentifier) JobIdentifier(com.thoughtworks.go.domain.JobIdentifier) JobConfigIdentifier(com.thoughtworks.go.domain.JobConfigIdentifier)

Example 2 with PipelineIdentifier

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

the class DownstreamInstancePopulator method populateRevisionsForAllChildrenOf.

private void populateRevisionsForAllChildrenOf(Node node, Set<Revision> visitedRevisions) {
    for (Revision revision : node.revisions()) {
        if (visitedRevisions.contains(revision)) {
            continue;
        }
        visitedRevisions.add(revision);
        for (Node child : node.getChildren()) {
            List<PipelineIdentifier> pipelineIdentifiers = pipelineDao.getPipelineInstancesTriggeredWithDependencyMaterial(child.getName(), ((PipelineRevision) revision).getPipelineIdentifier());
            addRevisionsToNode(child, pipelineIdentifiers);
            populateRevisionsForAllChildrenOf(child, visitedRevisions);
        }
    }
}
Also used : Revision(com.thoughtworks.go.domain.valuestreammap.Revision) PipelineRevision(com.thoughtworks.go.domain.valuestreammap.PipelineRevision) PipelineIdentifier(com.thoughtworks.go.domain.PipelineIdentifier) Node(com.thoughtworks.go.domain.valuestreammap.Node)

Example 3 with PipelineIdentifier

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

the class PipelineUnlockApiServiceTest method shouldBeAbleToVerifyUnlockStatusOfAPipelineWithoutCheckingForUserPermissions.

@Test
public void shouldBeAbleToVerifyUnlockStatusOfAPipelineWithoutCheckingForUserPermissions() throws Exception {
    when(goConfigService.isLockable("pipeline-name")).thenReturn(true);
    when(pipelineLockService.lockedPipeline("pipeline-name")).thenReturn(new StageIdentifier("pipeline-name", 10, "10", "stage", "2"));
    when(stageService.isAnyStageActiveForPipeline(new PipelineIdentifier("pipeline-name", 10, "10"))).thenReturn(false);
    assertThat(pipelineUnlockApiService.isUnlockable("pipeline-name"), is(true));
    verify(pipelineLockService, times(0)).unlock("pipeline-name");
}
Also used : StageIdentifier(com.thoughtworks.go.domain.StageIdentifier) PipelineIdentifier(com.thoughtworks.go.domain.PipelineIdentifier) Test(org.junit.jupiter.api.Test)

Example 4 with PipelineIdentifier

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

the class StageLockCheckerTest method setUp.

@BeforeEach
public void setUp() throws Exception {
    lockService = Mockito.mock(PipelineLockService.class);
    pipeline = new PipelineIdentifier("mingle", 10, "2.0.10");
    checker = new StageLockChecker(pipeline, lockService);
    result = new HttpOperationResult();
}
Also used : HttpOperationResult(com.thoughtworks.go.server.service.result.HttpOperationResult) PipelineIdentifier(com.thoughtworks.go.domain.PipelineIdentifier) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 5 with PipelineIdentifier

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

the class FailedBuildHistoryCacheSweeperTest method shouldClearFbhForPipelinesAfterUpdatedPipeline.

@Test
public void shouldClearFbhForPipelinesAfterUpdatedPipeline() {
    PipelineIdentifier pipelineIdentifier = entryAfterNew.getPipelineLocator();
    Stage stage = StageMother.cancelledStage("dev", "rspec");
    stage.setIdentifier(new StageIdentifier(pipelineIdentifier, "dev", "2"));
    String pipelineKey = key.forFbhOfStagesUnderPipeline(pipelineIdentifier);
    String stageKey = key.forFailedBuildHistoryStage(stage, "html");
    goCache.put(pipelineKey, stageKey, "fragment");
    sweeper.added(newlyAddedEntry, timeline);
    assertThat(goCache.get(pipelineKey), is(nullValue()));
}
Also used : StageIdentifier(com.thoughtworks.go.domain.StageIdentifier) PipelineIdentifier(com.thoughtworks.go.domain.PipelineIdentifier) Stage(com.thoughtworks.go.domain.Stage) Test(org.junit.jupiter.api.Test)

Aggregations

PipelineIdentifier (com.thoughtworks.go.domain.PipelineIdentifier)11 StageIdentifier (com.thoughtworks.go.domain.StageIdentifier)4 Test (org.junit.jupiter.api.Test)4 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)2 Node (com.thoughtworks.go.domain.valuestreammap.Node)2 HttpOperationResult (com.thoughtworks.go.server.service.result.HttpOperationResult)2 Test (org.junit.Test)2 BeforeEach (org.junit.jupiter.api.BeforeEach)2 RecordNotFoundException (com.thoughtworks.go.config.exceptions.RecordNotFoundException)1 JobConfigIdentifier (com.thoughtworks.go.domain.JobConfigIdentifier)1 JobIdentifier (com.thoughtworks.go.domain.JobIdentifier)1 Stage (com.thoughtworks.go.domain.Stage)1 PipelineRevision (com.thoughtworks.go.domain.valuestreammap.PipelineRevision)1 Revision (com.thoughtworks.go.domain.valuestreammap.Revision)1 Username (com.thoughtworks.go.server.domain.Username)1 ServerHealthStateOperationResult (com.thoughtworks.go.server.service.result.ServerHealthStateOperationResult)1 Matchers.containsString (org.hamcrest.Matchers.containsString)1