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;
}
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);
}
}
}
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");
}
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();
}
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()));
}
Aggregations