Search in sources :

Example 46 with MaterialConfigs

use of com.thoughtworks.go.config.materials.MaterialConfigs in project gocd by gocd.

the class PartialConfigMother method withPipelineMultipleMaterials.

public static PartialConfig withPipelineMultipleMaterials(String name, RepoConfigOrigin repoOrigin) {
    GitMaterialConfig gitMaterialConfig = MaterialConfigsMother.gitMaterialConfig();
    gitMaterialConfig.setFolder("git");
    SvnMaterialConfig svnMaterialConfig = MaterialConfigsMother.svnMaterialConfig();
    svnMaterialConfig.setFolder("svn");
    PipelineConfig pipe = PipelineConfigMother.pipelineConfig(name, new MaterialConfigs(gitMaterialConfig, svnMaterialConfig));
    BasicPipelineConfigs pipes = new BasicPipelineConfigs(pipe);
    pipes.setGroup("group");
    PartialConfig partialConfig = new PartialConfig(new PipelineGroups(pipes));
    partialConfig.setOrigins(repoOrigin);
    return partialConfig;
}
Also used : PipelineGroups(com.thoughtworks.go.domain.PipelineGroups) MaterialConfigs(com.thoughtworks.go.config.materials.MaterialConfigs) GitMaterialConfig(com.thoughtworks.go.config.materials.git.GitMaterialConfig) PartialConfig(com.thoughtworks.go.config.remote.PartialConfig) SvnMaterialConfig(com.thoughtworks.go.config.materials.svn.SvnMaterialConfig)

Example 47 with MaterialConfigs

use of com.thoughtworks.go.config.materials.MaterialConfigs in project gocd by gocd.

the class ScheduledPipelineLoader method knownMaterials.

private MaterialConfigs knownMaterials(Pipeline pipeline, MaterialRevisions scheduledRevs) {
    CruiseConfig currentConfig = goConfigService.getCurrentConfig();
    MaterialConfigs configuredMaterials = new MaterialConfigs();
    for (MaterialRevision revision : scheduledRevs) {
        String fingerprint = revision.getMaterial().getFingerprint();
        // first try to find material config from current pipeline config
        MaterialConfig configuredMaterial = currentConfig.materialConfigFor(new CaseInsensitiveString(pipeline.getName()), fingerprint);
        if (configuredMaterial != null) {
            configuredMaterials.add(configuredMaterial);
            continue;
        }
        // todo: remove the global lookup fallback code after we feel safe
        if (new SystemEnvironment().get(SystemEnvironment.GO_SERVER_SCHEDULED_PIPELINE_LOADER_GLOBAL_MATERIAL_LOOKUP)) {
            // fallback to global lookup if material is not in current pipeline config (old behavior)
            configuredMaterial = currentConfig.materialConfigFor(fingerprint);
            if (configuredMaterial != null) {
                configuredMaterials.add((configuredMaterial));
            }
        }
    }
    MaterialConfigs knownMaterials = new MaterialConfigs();
    for (MaterialConfig configuredMaterial : configuredMaterials) {
        materialExpansionService.expandForScheduling(configuredMaterial, knownMaterials);
    }
    return knownMaterials;
}
Also used : SystemEnvironment(com.thoughtworks.go.util.SystemEnvironment) MaterialConfigs(com.thoughtworks.go.config.materials.MaterialConfigs) MaterialConfig(com.thoughtworks.go.domain.materials.MaterialConfig) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) MaterialRevision(com.thoughtworks.go.domain.MaterialRevision) CruiseConfig(com.thoughtworks.go.config.CruiseConfig) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString)

Example 48 with MaterialConfigs

use of com.thoughtworks.go.config.materials.MaterialConfigs in project gocd by gocd.

the class FanInGraph method createFinalRevisionsForScmChildren.

private List<MaterialRevision> createFinalRevisionsForScmChildren(PipelineTimelineEntry latestRootNodeInstance, List<RootFanInNode> scmChildren, List<DependencyFanInNode> depChildren) {
    Set<FaninScmMaterial> scmMaterialsFromDepChildren = scmMaterialsOfDepChildren(depChildren);
    List<MaterialRevision> finalRevisions = new ArrayList<>();
    for (RootFanInNode child : scmChildren) {
        child.setScmRevision(scmMaterialsFromDepChildren);
        MaterialConfig materialConfig = child.materialConfig;
        Material material = materialConfigConverter.toMaterial(materialConfig);
        MaterialRevision revision = new MaterialRevision(material);
        if (latestRootNodeInstance != null) {
            PipelineInstanceModel pipeline = pipelineDao.findPipelineHistoryByNameAndCounter(latestRootNodeInstance.getPipelineName(), latestRootNodeInstance.getCounter());
            for (MaterialRevision materialRevision : pipeline.getCurrentRevisions()) {
                if (materialRevision.getMaterial().getFingerprint().equals(child.materialConfig.getFingerprint())) {
                    List<Modification> modificationsSince = materialRepository.findModificationsSinceAndUptil(material, materialRevision, child.scmRevision);
                    revision.addModifications(modificationsSince);
                    break;
                }
            }
        }
        if (revision.getModifications().isEmpty() && child.scmRevision == null) {
            MaterialRevisions latestRevisions = materialRepository.findLatestRevisions(new MaterialConfigs(materialConfig));
            finalRevisions.addAll(latestRevisions.getRevisions());
            continue;
        }
        if (revision.getModifications().isEmpty()) {
            revision = new MaterialRevision(material, materialRepository.findModificationWithRevision(material, child.scmRevision.revision));
        }
        finalRevisions.add(revision);
    }
    return finalRevisions;
}
Also used : Modification(com.thoughtworks.go.domain.materials.Modification) MaterialConfigs(com.thoughtworks.go.config.materials.MaterialConfigs) MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) Material(com.thoughtworks.go.domain.materials.Material) PipelineInstanceModel(com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModel) MaterialConfig(com.thoughtworks.go.domain.materials.MaterialConfig) DependencyMaterialConfig(com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig) ScmMaterialConfig(com.thoughtworks.go.config.materials.ScmMaterialConfig) MaterialRevision(com.thoughtworks.go.domain.MaterialRevision)

Example 49 with MaterialConfigs

use of com.thoughtworks.go.config.materials.MaterialConfigs in project gocd by gocd.

the class DeletePackageRepositoryCommandTest method shouldNotDeletePackageRepositoryIfItIsUsedAsAMaterialInPipeline.

@Test
public void shouldNotDeletePackageRepositoryIfItIsUsedAsAMaterialInPipeline() throws Exception {
    PackageDefinition pkg = new PackageDefinition();
    pkg.setId("pkg");
    packageRepository.addPackage(pkg);
    PackageMaterialConfig packageMaterial = new PackageMaterialConfig("pkg");
    PipelineConfig pipeline = new PipelineConfig();
    pipeline.setMaterialConfigs(new MaterialConfigs(packageMaterial));
    cruiseConfig.addPipeline("first", pipeline);
    assertThat(cruiseConfig.getPackageRepositories().size(), is(1));
    assertThat(cruiseConfig.getPackageRepositories().find(repoId), is(packageRepository));
    DeletePackageRepositoryCommand command = new DeletePackageRepositoryCommand(goConfigService, packageRepository, currentUser, result);
    command.update(cruiseConfig);
    assertFalse(command.isValid(cruiseConfig));
}
Also used : MaterialConfigs(com.thoughtworks.go.config.materials.MaterialConfigs) PackageMaterialConfig(com.thoughtworks.go.config.materials.PackageMaterialConfig) PipelineConfig(com.thoughtworks.go.config.PipelineConfig) PackageDefinition(com.thoughtworks.go.domain.packagerepository.PackageDefinition) Test(org.junit.Test)

Example 50 with MaterialConfigs

use of com.thoughtworks.go.config.materials.MaterialConfigs in project gocd by gocd.

the class GoConfigService method findMaterial.

public MaterialConfig findMaterial(final CaseInsensitiveString pipeline, String pipelineUniqueFingerprint) {
    MaterialConfigs materialConfigs = materialConfigsFor(pipeline);
    for (MaterialConfig materialConfig : materialConfigs) {
        if (pipelineUniqueFingerprint.equals(materialConfig.getPipelineUniqueFingerprint())) {
            return materialConfig;
        }
    }
    LOGGER.error("material with fingerprint [{}] not found in pipeline [{}]", pipelineUniqueFingerprint, pipeline);
    return null;
}
Also used : MaterialConfigs(com.thoughtworks.go.config.materials.MaterialConfigs) DependencyMaterialConfig(com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig) MaterialConfig(com.thoughtworks.go.domain.materials.MaterialConfig)

Aggregations

MaterialConfigs (com.thoughtworks.go.config.materials.MaterialConfigs)218 Test (org.junit.Test)158 DependencyMaterialConfig (com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig)35 MaterialConfig (com.thoughtworks.go.domain.materials.MaterialConfig)33 PipelineConfig (com.thoughtworks.go.config.PipelineConfig)32 BuildCause (com.thoughtworks.go.domain.buildcause.BuildCause)32 HgMaterial (com.thoughtworks.go.config.materials.mercurial.HgMaterial)27 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)25 GitMaterialConfig (com.thoughtworks.go.config.materials.git.GitMaterialConfig)25 SvnMaterialConfig (com.thoughtworks.go.config.materials.svn.SvnMaterialConfig)25 TimeProvider (com.thoughtworks.go.util.TimeProvider)25 GitMaterial (com.thoughtworks.go.config.materials.git.GitMaterial)21 DependencyMaterial (com.thoughtworks.go.config.materials.dependency.DependencyMaterial)19 SvnMaterial (com.thoughtworks.go.config.materials.svn.SvnMaterial)19 ValueStreamMapPresentationModel (com.thoughtworks.go.server.presentation.models.ValueStreamMapPresentationModel)16 PackageMaterialConfig (com.thoughtworks.go.config.materials.PackageMaterialConfig)15 HgMaterialConfig (com.thoughtworks.go.config.materials.mercurial.HgMaterialConfig)14 MaterialRevisions (com.thoughtworks.go.domain.MaterialRevisions)14 Material (com.thoughtworks.go.domain.materials.Material)14 Materials (com.thoughtworks.go.config.materials.Materials)12