use of com.thoughtworks.go.domain.StageIdentifier in project gocd by gocd.
the class PipelineDependencyGraphOldTest method assertThatTriggerIsPossibleOnlyIfUpStreamPassed.
private void assertThatTriggerIsPossibleOnlyIfUpStreamPassed(StageResult upstreamResult) {
StageInstanceModels stages = new StageInstanceModels();
stages.add(new StageInstanceModel("stage-0", "21", upstreamResult, new StageIdentifier("blahUpStream", 23, "stage-0", "21")));
PipelineInstanceModel upStream = PipelineHistoryMother.singlePipeline("blahUpStream", stages);
PipelineInstanceModel down1 = pim("blahDown1");
down1.setMaterialConfigs(new MaterialConfigs(dependencyMaterialConfig("blahUpStream", "stage-0")));
PipelineDependencyGraphOld graph = new PipelineDependencyGraphOld(upStream, PipelineInstanceModels.createPipelineInstanceModels(down1));
assertThat(graph.hasUpStreamRevisionFor(graph.dependencies().find("blahDown1")), is(upstreamResult == StageResult.Passed));
}
use of com.thoughtworks.go.domain.StageIdentifier in project gocd by gocd.
the class PipelineDependencyGraphOldTest method shouldProvideMaterialRevisionForAGivenDownStreamPipeline.
@Test
public void shouldProvideMaterialRevisionForAGivenDownStreamPipeline() throws Exception {
StageInstanceModels stages = new StageInstanceModels();
stages.add(new StageInstanceModel("stage-0", "21", StageResult.Cancelled, new StageIdentifier("blahUpStream", 23, "stage-0", "21")));
stages.add(new StageInstanceModel("stage-1", "2", StageResult.Cancelled, new StageIdentifier("blahUpStream", 23, "stage-1", "2")));
PipelineInstanceModel upStream = PipelineHistoryMother.singlePipeline("blahUpStream", stages);
PipelineInstanceModel down1 = pim("blahDown1");
down1.setMaterialConfigs(new MaterialConfigs(dependencyMaterialConfig("blahUpStream", "stage-0")));
PipelineInstanceModel down2 = pim("blahDown2");
down2.setMaterialConfigs(new MaterialConfigs(dependencyMaterialConfig("blahUpStream", "stage-1")));
PipelineDependencyGraphOld graph = new PipelineDependencyGraphOld(upStream, PipelineInstanceModels.createPipelineInstanceModels(down1, down2));
assertThat(graph.dependencyRevisionFor(down1), is("blahUpStream/23/stage-0/21"));
assertThat(graph.dependencyRevisionFor(down2), is("blahUpStream/23/stage-1/2"));
}
use of com.thoughtworks.go.domain.StageIdentifier in project gocd by gocd.
the class FetchTaskBuilder method resolveTargetJob.
private JobIdentifier resolveTargetJob(FetchTask task, Pipeline currentPipeline, UpstreamPipelineResolver resolver) {
PathFromAncestor pipelineNamePathFromAncestor = task.getPipelineNamePathFromAncestor();
if (pipelineNamePathFromAncestor == null || CaseInsensitiveString.isBlank(pipelineNamePathFromAncestor.getPath()) || CaseInsensitiveString.areEqual(new CaseInsensitiveString(currentPipeline.getName()), pipelineNamePathFromAncestor.getPath())) {
task.setPipelineName(new CaseInsensitiveString(currentPipeline.getName()));
String stageCounter = JobIdentifier.LATEST;
if (currentPipeline.hasStageBeenRun(CaseInsensitiveString.str(task.getStage()))) {
stageCounter = String.valueOf(currentPipeline.findStage(CaseInsensitiveString.str(task.getStage())).getCounter());
}
return new JobIdentifier(new StageIdentifier(currentPipeline.getName(), currentPipeline.getCounter(), currentPipeline.getLabel(), CaseInsensitiveString.str(task.getStage()), stageCounter), CaseInsensitiveString.str(task.getJob()));
} else {
DependencyMaterialRevision revision = null;
if (pipelineNamePathFromAncestor.isAncestor()) {
BuildCause buildCause = currentPipeline.getBuildCause();
for (CaseInsensitiveString parentPipelineName : pipelineNamePathFromAncestor.pathToAncestor()) {
DependencyMaterialRevision dependencyMaterialRevision = dmrForPipeline(parentPipelineName, buildCause);
if (dependencyMaterialRevision == null) {
throw bomb(String.format("Pipeline [%s] could not fetch artifact [%s]. Unable to resolve revision for [%s] from build cause", currentPipeline.getName(), task, parentPipelineName));
}
buildCause = resolver.buildCauseFor(dependencyMaterialRevision.getPipelineName(), dependencyMaterialRevision.getPipelineCounter());
}
revision = dmrForPipeline(pipelineNamePathFromAncestor.getAncestorName(), buildCause);
if (revision == null) {
throw bomb(String.format("Pipeline [%s] could not fetch artifact [%s]. Unable to resolve revision for [%s] from build cause", currentPipeline.getName(), task, pipelineNamePathFromAncestor.getAncestorName()));
}
} else {
revision = dmrForPipeline(pipelineNamePathFromAncestor.getPath(), currentPipeline.getBuildCause());
if (revision == null) {
throw bomb(String.format("Pipeline [%s] tries to fetch artifact from job [%s/%s/%s] " + "which is not a dependency material", currentPipeline.getName(), pipelineNamePathFromAncestor, task.getStage(), task.getJob()));
}
}
String stageCounter = JobIdentifier.LATEST;
if (task.getStage().equals(new CaseInsensitiveString(revision.getStageName()))) {
stageCounter = String.valueOf(revision.getStageCounter());
}
return new JobIdentifier(new StageIdentifier(CaseInsensitiveString.str(pipelineNamePathFromAncestor.getAncestorName()), revision.getPipelineCounter(), revision.getPipelineLabel(), CaseInsensitiveString.str(task.getStage()), stageCounter), CaseInsensitiveString.str(task.getJob()));
}
}
use of com.thoughtworks.go.domain.StageIdentifier 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
*/
public JobIdentifier findJob(String pipelineName, String counterOrLabel, String stageName, String stageCounter, String buildName, Long buildId) {
JobConfigIdentifier jobConfig = goConfigService.translateToActualCase(new JobConfigIdentifier(pipelineName, stageName, buildName));
Pipeline pipeline = pipelineService.findPipelineByCounterOrLabel(jobConfig.getPipelineName(), counterOrLabel);
stageCounter = StringUtils.isEmpty(stageCounter) ? JobIdentifier.LATEST : stageCounter;
StageIdentifier stageIdentifier = translateStageCounter(pipeline.getIdentifier(), jobConfig.getStageName(), stageCounter);
JobIdentifier jobId;
if (buildId == null) {
jobId = jobResolverService.actualJobIdentifier(new JobIdentifier(stageIdentifier, jobConfig.getJobName()));
} else {
jobId = new JobIdentifier(stageIdentifier, jobConfig.getJobName(), buildId);
}
if (jobId == null) {
//fix for #5739
throw new JobNotFoundException(pipelineName, stageName, buildName);
}
return jobId;
}
use of com.thoughtworks.go.domain.StageIdentifier in project gocd by gocd.
the class ShineDaoIntegrationTest method shouldRetriveTheRightHistoricalFailureInformationForPipelinesWithSameLabel.
@Test
public void shouldRetriveTheRightHistoricalFailureInformationForPipelinesWithSameLabel() throws Exception {
Pipeline pipeline1 = pipeline;
failureSetup.setupPipelineInstance(true, pipeline1.getLabel(), goURLRepository);
StageIdentifier stageId3 = failureSetup.setupPipelineInstance(true, pipeline1.getLabel(), goURLRepository).stageId;
StageTestRuns stageTestRuns = shineDao.failedBuildHistoryForStage(stageId3, result);
List<FailingTestsInPipeline> failingTestsInPipelines = stageTestRuns.failingTestsInPipelines();
assertThat(failingTestsInPipelines.size(), is(3));
FailingTestsInPipeline failingPipeline3 = failingTestsInPipelines.get(0);
assertThat(failingPipeline3.getLabel(), is(pipeline1.getLabel()));
assertThat(failingPipeline3.failingSuites().size(), is(0));
FailingTestsInPipeline failingPipeline2 = failingTestsInPipelines.get(1);
assertThat(failingPipeline2.getLabel(), is(pipeline1.getLabel()));
assertThat(failingPipeline2.failingSuites().size(), is(0));
FailingTestsInPipeline failingPipeline1 = failingTestsInPipelines.get(2);
assertThat(failingPipeline1.getLabel(), is(pipeline1.getLabel()));
List<TestSuite> suites = failingPipeline1.failingSuites();
assertThat(suites.size(), is(1));
assertThat(suites.get(0).countOfStatus(TestStatus.Error), is(1));
assertThat(suites.get(0).countOfStatus(TestStatus.Failure), is(1));
}
Aggregations